简体   繁体   中英

How to retrieve data from multiple checkbox which is built from .cs file with newCell.Text

I'm new at C# and I'm trying to retrieve data from multiple checkbox and I built it from .cs file with C# code.

These are the codes

newCell.Text += "<table id=\"CheckBoxList1\" class=\"checkboxlist\"><tbody>";
newCell.Text += "<tr><td>";
newCell.Text += "<input class=\"styled\" id=\"CheckBoxList1_0\" type=\"checkbox\" 
value=\"Value\" name=\"CheckBoxList1$\"></input>";
newCell.Text += "<label for=\"CheckBoxList1_0\">Text</label></td></tr>";
newCell.Text += "</tbody></table>";

There are 2 datas in database and I fetch them using these codes. I want to retrieve data(s) to TextBox which checkbox is selected.

Thank you

All the post back data exist on the Request.Form and to get one of them you use the name parameter of your control, in your case:

Request.Form["CheckBoxList1$"]

When you have a dynamic named control from asp.net you use the UniqueID of the control, as:

Request.Form[ControlID.UniqueID]

or in most case the asp.net is control the post back data and add it to some value of the control, eg on TextBoxes, the .Text keep the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM