在编辑列中有一个RadioButtonList控件,需要根据库中的值来确定哪个项是否选中
可是如下的代码却一直提示 未将对象引用设置到对象的实例。
请问这是为何呢
protected void GvGradeType_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("RblAttr");
rbl.SelectedValue = GvGradeType.DataKeys[e.Row.RowIndex][1].ToString();
}
}
可是如下的代码却一直提示 未将对象引用设置到对象的实例。
请问这是为何呢
protected void GvGradeType_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("RblAttr");
rbl.SelectedValue = GvGradeType.DataKeys[e.Row.RowIndex][1].ToString();
}
}
怪事了
大猫猫,那个DataKeys我有两个参数的,所以取的是1