Link to home
Start Free TrialLog in
Avatar of AVARICESOFT
AVARICESOFTFlag for Pakistan

asked on

not get the selectvalue in dropdown

hello,

i ask this question: https://www.experts-exchange.com/questions/24991457/how-to-add-data-in-dropdown-using-database-using-C-net.html?anchorAnswerId=26087358#a26087358

its work well but their is a little problem .. when i select any item which are on my dropdown value then its always show me on the first value..

i print the selected item value in label on button click event..


protected void Button1_Click1(object sender, EventArgs e)
    {
            
        
        Label1.Text = ddl_customer.SelectedValue.ToString();

     }


// its always gives me the only first item value how why..

Open in new window

Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

could you upload code of your page_LOAD method here
I think you fill this dropdown when page loads and you don't expect IsPostBack. am I right?
if this is right you must put your fill code line inside an if like this:

if(!IsPostBack)
{
dropdown1.DataSource=something;
}
Avatar of AVARICESOFT

ASKER

Both DataSource and DataSourceID are defined onBoth DataSource and DataSourceID are defined on dropdownlist"



i get an error on the following: when i debug the code



"Both DataSource and DataSourceID are defined on dropdownlist"
i get an error on the following: when i debug the code



"Both DataSource and DataSourceID are defined on dropdownlist"

ddl_customer.DataBind();
ASKER CERTIFIED SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
problem solved..
Glad to help,
Regards,