Dropdown list,Databound ,Unable to select an item in list after databinding [Resolved]

Posted by Raja_89 under C# on 9/15/2016 | Points: 10 | Views : 251 | Status : [Member] | Replies : 1
Hai

I am binding values from sql db to dropdown with default value

After selecting an item after databinding only default value is there by using Dropdown.selectedvalue snippet

How can i get selected value

Example
Dropdown.Datasource=Dttable;
Dropdown.DataTextvalue="v1";
Dropdown.datavaluefield="v2";
Dropdown.databind();
Dropdown.items.insert("0",Select");

checked with

Autopostback=true
AppendDataBoundItems="True" EnableViewState="False"
for that dropdown control in design view



Selected_IndexChanged()
{
String str=Dropdown.selectedvalue and Dropdown.selecteditem

}


Value after keeping breakpoint

str="select"


Help me to find the solution

Regards




Responses

Posted by: Bhupentiwari on: 9/27/2016 [Member] Starter | Points: 50

Up
0
Down

Resolved
The bind method to dropdown should be called inside

if(!ispostback){
Call your method which binds dropdown
}


Thanks n Regards
Bhupendra Tiwari

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response