Jae*_*ebi 0 html c# asp.net html-table
我在aspx页面(C#)中有一个html表,其中包含类似的列
1.CheckBox 2.Text 3.Text 4.TextBox
Run Code Online (Sandbox Code Playgroud)
我希望一次一行地遍历表并根据是否选中该复选框来处理(基于column2运行存储过程).我怎么能这样做?
假设您正在使用Table服务器控件,那么它只是:
foreach (TableRow row in table.Rows)
{
var checkBox = (CheckBox)row.Cells[0].Controls[0]; //Assuming the first control of the first cell is always a CheckBox.
if (checkBox.Checked)
{
var col2 = (TextBox)row.Cells[1].Controls[0];
/* Do Stuff With col2 */
}
else
{
/* Do Stuff */
}
}
Run Code Online (Sandbox Code Playgroud)
如果您只使用常规html表(使用runat ="server")以及html表单控件,则只需将TableRow更改为HtmlTableRow,将CheckBox更改为HtmlInputCheckBox,将TextBox更改为HtmlInputText.所有这些控件都在System.Web.UI.HtmlControls命名空间中.
| 归档时间: |
|
| 查看次数: |
21068 次 |
| 最近记录: |