服务器端的CheckBox应该没有Value这个说法吧,是不是Text啊 If IsPostBack Then If CType(tblDetail.Items(0).FindControl("chkSelet"),CheckBox).checked = True Then Response.Write(CType(tblDetail.Items(0).FindControl("chkSelet"),CheckBox).Text) End IfEnd If
这样不对呀 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 行 73: 行 74: If IsPostBack Then 行 75: If CType(tblDetail.Items(0).FindControl("chkSelet"), CheckBox).Checked = True Then 行 76: 'Response.Write(CType(tblDetail.Items(0).FindControl("chkSelet"), CheckBox).Text) 行 77: Response.Write("This is Daniel Testing ")
foreach(DataGridItem it in this.DataGrid1.Items) { System.Web.UI.WebControls.CheckBox ChB=(System.Web.UI.WebControls.CheckBox)it.Cells[0].FindControl("CheckBox1"); if(ChB.Checked==true)//selected { dosomthing.....} }
If IsPostBack Then
If CType(tblDetail.Items(0).FindControl("chkSelet"),CheckBox).checked = True Then
Response.Write(CType(tblDetail.Items(0).FindControl("chkSelet"),CheckBox).Text) End IfEnd If
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 73:
行 74: If IsPostBack Then
行 75: If CType(tblDetail.Items(0).FindControl("chkSelet"), CheckBox).Checked = True Then
行 76: 'Response.Write(CType(tblDetail.Items(0).FindControl("chkSelet"), CheckBox).Text)
行 77: Response.Write("This is Daniel Testing ")
{
System.Web.UI.WebControls.CheckBox ChB=(System.Web.UI.WebControls.CheckBox)it.Cells[0].FindControl("CheckBox1");
if(ChB.Checked==true)//selected
{
dosomthing.....}
}