alright
asked on
Modify control's Enabled property without postback?
I have within the EmptyDataTemplate of a GridView a RadioButtonList, a DropDownList and a DetailsView control. I would like, based on which of the two values of the RBL is selected, for the DDL or DV control's Enabled property to change to true/false. I've accomplished this thru the following code-behind in the RBL's SelectedIndexChanged command but this requires AutoPostBack which causes the user to lose their place on the page as the page reloads scrolled to the top etc. It's not very elegant :( Is there a better way?
protected void RadioButtonList1_SelectedI ndexChange d(object sender, EventArgs e)
{
RadioButtonList rbl = (RadioButtonList)sender;
DropDownList ddl = (DropDownList)(rbl.NamingC ontainer.F indControl ("DropDown List1"));
DetailsView dv = (DetailsView)(rbl.NamingCo ntainer.Fi ndControl( "DetailsVi ew1"));
if (rbl.SelectedValue == "1")
{
ddl.Enabled = true;
dv.Enabled = false;
}
else
{
ddl.Enabled = false;
dv.Enabled = true;
}
}
protected void RadioButtonList1_SelectedI
{
RadioButtonList rbl = (RadioButtonList)sender;
DropDownList ddl = (DropDownList)(rbl.NamingC
DetailsView dv = (DetailsView)(rbl.NamingCo
if (rbl.SelectedValue == "1")
{
ddl.Enabled = true;
dv.Enabled = false;
}
else
{
ddl.Enabled = false;
dv.Enabled = true;
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.