Do the following:
1. Add an
OnRowDataBound
event to the
GridView
(say,
OnRowDataBound="InTransitGridView_RowDataBound"
) and remove the
OnRowCommand
and
onselectedindexchanged
events.
2. Add the following code in the Code Behind (To bind each radio button control with a JavaScript
onclick
event method):
protected void InTransitGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
RadioButton decline = e.Row.FindControl("btn2") as RadioButton;
RadioButton accept = e.Row.FindControl("btn1") as RadioButton;
DropDownList ddlStatus = e.Row.FindControl("ddlUSG_PRD_STATUS") as DropDownList;
if (decline != null && ddlStatus != null && accept != null)
{
decline.Attributes["onclick"] = "EnableDisableControl(this,0,'" + ddlStatus.ClientID + "')";
accept.Attributes["onclick"] = "EnableDisableControl(this,1,'" + ddlStatus.ClientID + "')";
}
}
}:
3. In the Markup, define a JavaScript method as follows (that enables or disables the drop-down list based upon the selection):
<script language="javascript">
function EnableDisableControl(radio, isDisable, dropDownListId)
{
var dropDownList = document.getElementById(dropDownListId);
if(radio.checked)
{
if(isDisable == 0)
{
dropDownList.disabled = "disabled";
}
else
{
dropDownList.disabled = "";
}
}
}
</script>
Hopefully, your problem will be solved.
Note: I didn't check the cross-browser issues for the JavaScript, tested only in FireFox. I believe you can handle this.