c# - Not able to set dropdownlist at page load -


i getting first time kind of problem

i setting value of dropdownlist @ page load dataset auto setting 0 index ..... code :

ddlebitda.selectedvalue = objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); 

i checked @ immediate windows ...

objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); 

"between 40-60 %" ( come value data set right)

ddlebitda.selectedvalue "up 10 million dollar "           ( default value setting ) 

i tried many different code solve problem :

    ddlebitda.clearselection();     string ebitda = objdataset.tables[0].rows[0]["acq_ebitda"].tostring();     ddlebitda.items.findbyvalue(ebitda).selected = true;       string ebitda = objdataset.tables[0].rows[0]["acq_ebitda"].tostring();     ddlebitda.selectedindex = ddlebitda.items.indexof(ddlebitda.items.findbyvalue(ebitda)); 

but still not able solve problem ....truth not able understand problem .....

this should work

string value=objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); ddlebitda.items.findbyvalue(value).selected = true; 

but make sure when binding dropdown datasource, @ time acq_ebitda should datavaluefield.

if datatextfield should try this

ddlebitda.items.findbytext(value).selected = true; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -