Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

DropDownList postback problem

Hi,
    I'm having difficulty figuring out how to keep a drop down from repopulating after a SelectedIndexChange event, here let me show you the code.

private void Page_Load(object sender, System.EventArgs e)
            {
                                      PopulateProducts();
                                  }
PolulateProducts fills the list from a table in a db.  I have a problem when the following event fires.

private void dd_products_SelectedIndexChanged_1(object sender, System.EventArgs e)
            {
                  LoadProductInfo(Convert.ToInt32(dd_products.SelectedIndex.ToString() ) );  //fills a dataset
                  FillProductInfo(ProductDataSet);  //fills fields in the form
                                                  //autopost back is TRUE
            }

When the post back occurs, it repopulates the DDL.  What is the "proper" way to handle this, I have tried a few “mickey mouse” ideas, but those caused other problems.  

Thanks
Sean






0
sean-keys
Asked:
sean-keys
1 Solution
 
brdrokCommented:
try this:

private void Page_Load(object sender, System.EventArgs e)
{
     if (!Page.IsPostBack)
     {
            PopulateProducts();
     }
}
0
 
sean-keysAuthor Commented:
That worked like this.

if (Page.IsPostBack)
{
}
else
{
     PopulateProducts();
}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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