function uncheckOthers(id) {
var elm = document.getElementsByTagName('input');
for (var i = 0; i < elm.length; i++) {
if (elm.item(i).id.substring(id.id.lastIndexOf('_')) == id.id.substring(id.id.lastIndexOf('_'))) {
if (elm.item(i).type == "radio" && elm.item(i) != id) elm.item(i).checked = false;
}
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//To make the RadioButton mutually exclusive
string strScript = "uncheckOthers(" + ((RadioButton)e.Row.Cells[0].FindControl("rbSelect")).ClientID + ");";
((RadioButton)e.Row.Cells[0].FindControl("rbSelect")).Attributes.Add("onclick", strScript);
}
}
catch (Exception ex)
{
throw ex;
}
}
No comments:
Post a Comment