I am new to MVC framework and here stucked with an updation method, can anyone help me?
MyCode in View :
<table>
<% if (Model == null || Model.Count <= 0)
{
%>
<tr>
<td >
No Records found !!.Please search.
</td>
</tr>
<% }
else
{
foreach (var item in Model)
{ %>
<tr>
<td>Id</td>
<td><%: item.ID %></td>
<tr>
<td > System : </td>
<td >
<input id="txtSystemName" value=' <%: item.System %>' type="text"style="height: 20px; width: 120px;" />
</td>
<td >TaskName :</td>
<td><input id="txtTaskName" value='<%: item.TaskName %>' class="TextBoxStyle" type="text"
style="height: 20px; width: 340px;" /><td/>
<tr>
<tr>
<td><input id="Submit1" name="btnSave" type="submit" value="Save" class="ButtonStyle"
style="width: 100px; height: 20px" /></td>
</tr>
<%
}
}
%>
The above is my code and here i will get the records in the view and the above code doesnt contain all the property i have pasted only 3 fields and wen i update some names in the input field and wen i clicked the button in that table i want to update only that record values for this i want to know how to call the controller method and and to pass the parameters to the method.
can anyone help me for this.
thanks in advance.
Here’s what I would suggest you. Start with a view model which will represent a table row:
then a controller which will contain actions for listing all models and updating a single row:
Then let’s move on to the main view (
~/Views/Home/Index.aspx):Then we define a partial for the view model (
~/Views/Home/_MyViewModel.ascx):and the last part is to AJAXify those forms. This could be done unobtrusively in a separate javascript file using jquery: