Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

not get the selectvalue in dropdown

hello,

i ask this question: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_24991457.html#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

0
AVARICESOFT
Asked:
AVARICESOFT
  • 4
  • 4
1 Solution
 
Reza RadCommented:
could you upload code of your page_LOAD method here
0
 
Reza RadCommented:
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;
}
0
 
AVARICESOFTAuthor Commented:

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



0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

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



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



"Both DataSource and DataSourceID are defined on dropdownlist"

ddl_customer.DataBind();
0
 
Reza RadCommented:
bring your page_load code here for deeper consideration
0
 
AVARICESOFTAuthor Commented:
problem solved..
0
 
Reza RadCommented:
Glad to help,
Regards,

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now