asp.net mvc - Render partial view in specific div -


i'm attempting create dynamic gird, or 1 appears dynamic. goal able search, view, edit , delete records single view using partial views. i'd behavior asp.net webforms gridview.

basically have table 3 columns. 1 id, other name. third hold simple commands such "save", "update", "cancel" on , forth.

i have separate views "_create", "_edit" , "_delete". currently, i'm rending them using method:

 public actionresult renderpartialview(string view, int? id)         {             if (id == null)             {                 return partialview(view);             }             else             {                 projectdata item = new projectdata();                                  //populate data                  return partialview(view, item);             }         }  @html.actionlink("edit", "renderpartialview", new { view = "_edit", id = @model.id.tostring() }) 

this render partial view correct data, not display in specific div correlates record. here view table , records looks like:

    @foreach (var item in model.source)     {         <div id="@item.projectid">             <tr>                 <td>                     @html.displayfor(modelitem => item.projectid)                 </td>                 <td>                     @html.displayfor(modelitem => item.name)                 </td>                 <td style="width: 100px; text-align: center;">                     @html.actionlink("edit", "renderpartialview", new { view = "_edit", id = @item.projectid })                 </td>             </tr>         </div>     } 

my partial view looks this:

@using (ajax.beginform("index", "project", null, new ajaxoptions() { updatetargetid = @model.projectid.tostring(), httpmethod = "get" }, new { })) {     @html.antiforgerytoken()      <tr>         <td>             @html.displayfor(modelitem => modelitem.projectid)         </td>         <td>             @html.textboxfor(modelitem => modelitem.name)         </td>         <td style="width: 100px; text-align: center;">             @html.actionlink("save", "save")             @html.actionlink("cancel", "renderpartialview", new { view = "???", id = "" })         </td>     </tr> } 

how go rendering partial view, in case "_edit" in specific div? thanks!

if want content display in td, need:

@html.action(...) 

not:

@html.actionlink("edit", "renderpartialview" 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -