gridview中使用RadioButtonList的问题

2024-12-01 10:30:26
推荐回答(2个)
回答1:

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string sex = (GridView1.Rows[e.NewEditIndex].FindControl("Label3") as Label).Text.Trim();
GridView1.EditIndex = e.NewEditIndex;
//蔽州为GridView1重新绑定数据;
RadioButtonList rbl = GridView1.Rows[e.NewEditIndex].FindControl("rblSex"悔棚) as RadioButtonList;
rbl.Items[0].Selected = sex == "男" ? true : false;
rbl.Items[1].Selected = sex == "女碧并则" ? true : false;
}

回答2:

不给你写代码槐厅枣伏数了,你首先用findcontrol找到铅拆RadioButtonList,这时候你就可以按照操作RadioButtonList 的方法获取你选中的项了