asp.net - Selecting radiobutton from codebehind -
i have set of 3 radiobuttons
on aspx page:
on pageload
setting default value code behind using following code:
rblistaccess.items.findbytext("page1scorecard poc").selected = true; rblistmetrictype.items.findbytext("non-percentage").selected = true; rblistmetricinterval.items.findbytext("monthly").selected = true;
this working fine.
on edit link,i fetching data backend , setting values again using data columns dataset fetched there not working. values not being selected correctly. cannot understand issue. randomly once or twice one/two of set being set correctly:
rblistaccess.items.findbytext(ds.tables[0].rows[0]["tobefilledby"].tostring()).selected = true; rblistmetrictype.items.findbytext(ds.tables[0].rows[0]["metrictype"].tostring()).selected=true; rblistmetricinterval.items.findbytext(ds.tables[0].rows[0]["metricinterval"].tostring()).selected = true;
please let me know issue.
you might want clear selection using clearselection()
method before assigning new value.
rblistaccess.clearselection(); // add radiobuttons rblistmetrictype.clearselection(); rblistmetrictype.clearselection(); rblistaccess.items.findbytext(ds.tables[0].rows[0]["tobefilledby"].tostring()).selected = true; rblistmetrictype.items.findbytext(ds.tables[0].rows[0]["metrictype"].tostring()).selected=true; rblistmetricinterval.items.findbytext(ds.tables[0].rows[0]["metricinterval"].tostring()).selected = true;
Comments
Post a Comment