我做的一个程序,使用的是GridView+模板列(加入的控件是RadioButton1),在使用的过程中,需要取出每一个列的值,进行判断
程序如下: if ((this.GridView1.Rows[i].FindControl("RadioButton1") as RadioButton).Checked)报的错误是:
索引超出范围。必须为非负值并小于集合大小。
参数名: 索引超出范围。必须为非负值并小于集合大小。
参数名: index
程序如下: if ((this.GridView1.Rows[i].FindControl("RadioButton1") as RadioButton).Checked)报的错误是:
索引超出范围。必须为非负值并小于集合大小。
参数名: 索引超出范围。必须为非负值并小于集合大小。
参数名: index
{}
或者在databound事件里面
protected void GridView1_DataBound(object sender, EventArgs e)
{
for(int i=0;i<GridView1.Rows.Count;i++)
{
if ((this.GridView1.Rows[i].FindControl("RadioButton1") as RadioButton).Checked)
.....
}
}