I'm trying to add a column with a checkbox (which I have managed with the ValueTemplate function), but I'm unable to add the required hidden inputs for the purposes of posting back the details of the items that have been checked. I need the html to look like this:
<input type="hidden" name="checkedItems[0].Index" value="0" />, which needs to occur once above the below examples, so that the default binder knows to post back an array of objects.
Row N - Checkbox Cell
And so on with the index being incremented by 1 per row.
My Model
public class Something
{
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
}
public class MyModel
{
public bool Selected { get; set; }
public string Field1 { get; set; }
public string Field2 { get; set; }
public List { get; set; }
}
Any advice on how to achieve this would be appreciated.
Thanks.
public class MyModel
{
public bool Selected { get; set; }
public string Field1 { get; set; }
public string Field2 { get; set; }
public List ListOfSomething { get; set; }
}
I'm trying to add a column with a checkbox (which I have managed with the ValueTemplate function), but I'm unable to add the required hidden inputs for the purposes of posting back the details of the items that have been checked. I need the html to look like this:
<input type="hidden" name="checkedItems[0].Index" value="0" />
, which needs to occur once above the below examples, so that the default binder knows to post back an array of objects.Row 1 - Checkbox Cell `
<input type="hidden" name="checkedItems[0].ListOfSomething[0].Field1" value="somevalue" ) /> <input type="hidden" name="checkedItems[0].ListOfSomething[0].Field2" value="somevalue" ) /> <input type="hidden" name="checkedItems[0].ListOfSomething[0].Field3" value="somevalue" ) /> <input type="hidden" name="checkedItems[0].ListOfSomething[1].Field1" value="somevalue" ) /> <input type="hidden" name="checkedItems[0].ListOfSomething[1].Field2" value="somevalue" ) /> <input type="hidden" name="checkedItems[0].ListOfSomething[1].Field3" value="somevalue" ) />`
Row 2 - Checkbox Cell `
<input type="hidden" name="checkedItems[1].ListOfSomething[0].Field1" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[0].Field2" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[0].Field3" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[1].Field1" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[1].Field2" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[1].Field3" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[2].Field1" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[2].Field2" value="someothervalue" ) /> <input type="hidden" name="checkedItems[1].ListOfSomething[2].Field3" value="someothervalue" ) />`
Row N - Checkbox Cell And so on with the index being incremented by 1 per row.
My Model public class Something { public string Field1 { get; set; } public string Field2 { get; set; } public string Field3 { get; set; } }
public class MyModel { public bool Selected { get; set; } public string Field1 { get; set; } public string Field2 { get; set; } { get; set; }
}
public List
Any advice on how to achieve this would be appreciated. Thanks.