views:

53

answers:

1

i have a form that i am submitting to my controller. I created a data class that is used to pass into my controller to do something like this:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Update(ApplicationUpdater applicationUpdater_)
    {
    }

the issue is i used to have a list in a multi select dropdown and that simple mapped to an array of strings in my binding data object.

public class ApplicationUpdater
{
    public string[] dependencies { get; set; }
}

the issue now is that i have to store more attributes so i changed the dropdown to a dynamically generated html table (table is generated using jquery)

so i have a table

<table border=1>
    <tr><td>Joe</td><td>Thompson</td></tr>
    <tr><td>Billy</td><td>Williams</td></tr>
</table>

and i want to convert these values into an array of Name objects where the first column is Name.First and the second column is Name.Last.

so in theory i could then have my binding object be something like this.

public class ApplicationUpdater
{
    public Name[] dependencies { get; set; }
}
+2  A: 

One Option is to set some hidden input fields like:

<table border=1>
    <tr>
        <td>
            Joe <input  TYPE="hidden" VALUE="Joe" NAME="applicationUpdater.Name[0].First">
         </td>
         <td>
            Thompson <input  TYPE="hidden" VALUE="Thompson" NAME="applicationUpdater.Name[0].Last">
         </td>
   </tr>
    <tr>
        <td>
            Billy <input  TYPE="hidden" VALUE="Billy" NAME="applicationUpdater.Name[1].First">
         </td>
         <td>
            William <input  TYPE="hidden" VALUE="William" NAME="applicationUpdater.Name[1].Last">
         </td>
   </tr>

</table>

You need to set this hidden fields so when the user post the form, the values get bind from this hidden fields, as the td's are not intent to be posted within a form.

Omar
excellent idea . .
ooo