2012年11月2日 星期五
GridView RaidoButon Group 不複選
//RadioButton加入事件
OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="true"
//RadioButton 事件CheckedChanged
protected void RadioButton_CheckedChanged(object sender, EventArgs e)
{
string RadioNowGUAR_SYSID = ((Label)((RadioButton)sender).NamingContainer.FindControl("lblGUAR_SYSID")).Text; //抓取當下RadioButton
string RadioNowACCT_DATA = ((Label)((RadioButton)sender).NamingContainer.FindControl("lblACCT_DATA")).Text; //抓取當下RadioButton
string tempGUAR_SYSID,tempACCT_DATA;
foreach (GridViewRow item in grid_view.Rows) //此為檢查是否有相同Group
{
if (((RadioButton)item.FindControl("RadioButton2")).Checked == true) //此為檢查是否為同Group
{
tempGUAR_SYSID = ((Label)item.FindControl("lblGUAR_SYSID")).Text;
tempACCT_DATA = ((Label)item.FindControl("lblACCT_DATA")).Text;
if (tempGUAR_SYSID == RadioNowGUAR_SYSID)
{
if (tempACCT_DATA != RadioNowACCT_DATA)
{
((RadioButton)item.FindControl("RadioButton2")).Checked = false;
}
}
}
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言