[英]How to retrieve data from multiple checkbox which is built from .cs file with newCell.Text
我是C#的新手,正嘗試從多個復選框中檢索數據,並使用C#代碼從.cs文件構建了該數據。
這些是代碼
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>";
數據庫中有2個數據,我使用這些代碼來獲取它們。 我想將數據檢索到已選中復選框的TextBox。
謝謝
所有回發數據都存在於Request.Form
,要獲得其中的一種,您可以使用控件的name
參數,在這種情況下:
Request.Form["CheckBoxList1$"]
當您從asp.net獲得動態命名控件時,可以使用該控件的UniqueID
,如下所示:
Request.Form[ControlID.UniqueID]
或在大多數情況下,asp.net是控件回發數據並將其添加到控件的某個值,例如在TextBoxes上, .Text
保留數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.