0

I am using the partial view with the ajax.beginform. In that partial view page, i have the following markup EDIT

<%
using (Ajax.BeginForm("ManageDataSources", "DataSources", saveAjaxOptions))
{
%>....
<td>
                <%: Html.Hidden("DataSource_Id", dataSource.Id, new { @class = "DataSource_Id" })%>
                <%: Html.TextBox("DataSource_Name", dataSource.Name, new { @class = "DataSource_Name" })%>
            </td>
 <tr class="queryParameters" style="display: block">

        <td colspan="2" align="center">

            <input id="Text1" name="parametername" type="text" />

            <input id="Text2" name="parametervalue" type="text" />

            <input id="Text3" name="parametername" type="text" />

            <input id="Text4" name="parametervalue" type="text" />

            <input id="Text5" name="parametername" type="text" />

            <input id="Text6" name="parametervalue" type="text" />

            <input id="Text7" name="parametername" type="text" />

            <input id="Text8" name="parametervalue" type="text" />

            <input id="Text9" name="parametername" type="text" />

            <input id="Text10" name="parametervalue" type="text" />

        </td>

    </tr>

and in the the controller, i have this model for the representation of the data

public class DataSourceViewModel
{
    public string DataSource_Id { get; set; }
    public string DataSource_Name { get; set; }
    public List<SCParams> parameters { get; set; }
}

public class SCParams
{
    public string parametername { get; set; }
    public string parametervalue { get; set; }
}

EDIT

public ActionResult ManageDataSources(DataSourceViewModel dsvm)
        {
            return PartialView("ManageDataSources");
        }

when i post the data these parametername and parameter values are not at all bound to the list of objects. How do i do this. i am using microsoft ajax and want to do this without using other plugings. Kindly suggest the right way.

EDIT

This is the data in the header taken from chrome

DataSource_Id:
DataSource_Name:Name
parametername:a
parametervalue:1
parametername:q
parametervalue:2
parametername:z
parametervalue:3
parametername:s
parametervalue:4
parametername:w
parametervalue:5
x:15
y:12
Saravanan
  • 7,637
  • 5
  • 41
  • 72
  • where is form in your code and where is your controller code – Tassadaque Jan 13 '12 at 13:11
  • @Tassadaque: Thought that this markup was sufficient, anyways.. i have updated the code. – Saravanan Jan 13 '12 at 13:14
  • @Tassadaque: I am able to get the values using this signature on the controller `public ActionResult ManageDataSources(string DataSource_Id,string DataSource_Name,string[] parametername, string[] parametervalue)`. but trying to get them in a dictionary or list of objects – Saravanan Jan 13 '12 at 13:27

1 Answers1

1

What I understand you have master detail structure and you want to receive it controller. if that is the case. then there are two possibilities either your detail portion has variable length detail portion or fixed length detail portion. You may follow the post here for variable length as well as fixed length. For Fixed length you may also follow here.

You will receive the model in following signature

public ActionResult ManageDataSources(DataSourceViewModel dsvm)

moreover you may also check formcollection parameter for actionresult

       [HttpPost]
        public ActionResult MyAction(FormCollection collection)
Tassadaque
  • 8,129
  • 13
  • 57
  • 89
  • Thanks for your reply. Can you pls clarify me the following doubts, 1. Why is the Queue always empty, 2. what is the purpose of HtmlFieldPrefixScope, i came to know that it is referring to some `MVC` Template, but can you explain me these points or point out a place where i can find more details on this, i am new to MVC2, so i want to learn these techniques. – Saravanan Jan 14 '12 at 05:50