【发布时间】:2016-06-16 05:24:49
【问题描述】:
我有一个 asp .Net 页面,其中有一个名为 rowId 的标签
protected void testResultsGridView_onRowUpdating(object sender, GridViewUpdateEventArgs e)
{
string str = string.Empty;
GridViewRow row = testResultsGridView.Rows[e.RowIndex];
Int32 id = Int32.Parse(((Label)row.FindControl("rowId")).Text);
String Cause = ((DropDownList)row.FindControl("Cause")).SelectedValue;
String comment = ((TextBox)row.FindControl("comment")).Text;
String check = ((TextBox)row.FindControl("check")).Text;
String reRunStatus = ((DropDownList)row.FindControl("Status")).SelectedValue;
String subCategory = ((DropDownList)row.FindControl("Category")).SelectedValue;
foreach (GridViewRow gvrow in testResultsGridView.Rows)
{
CheckBox chk = (CheckBox)gvrow.FindControl("cbSelect");
if (chk != null && chk.Checked)
{
id = Int32.Parse(((Label)gvrow.FindControl("rowId")).Text); ;
UpdateTestCase(id, rootCause, subCategory, comment, RTC, reRunStatus);
}
}
testResultsGridView.EditIndex = -1;
BindData();
}
在这种情况下,首先找到对 rowId 返回值的控件,然后在选定的 scheckbox 中找到第二个控件返回 null。我什至没有动态添加任何控件。可能是什么原因?
【问题讨论】: