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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -