Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Genius,
I am having a problem from last 6-7 hours in my project.
I am using a web server control where I am creating dynamic control according to selection of a dropdownlist of parent page(the control calling page).
So, According to the dropdownlist value the webserver will re-generate the controls.

Now, My code analysis:
I am creating properly the controls with
C#
protected override void CreateChildControls()
{
 // addding control stuff here..
}
protected override void RenderContents(HtmlTextWriter output)
{
 // render the controls stuff here..
}

The controls are creating successfully.
Now Problem:
When I am changing the dropdownlist data from parent page, the "CreateChildControls()" method calling but the Changing dropdown selected value is not getting. So, This method working with previous selected data. Because After Executing CreateChildControls()method, the SelectedIndexChanged event fires.

I already searched many links but didn't find the answer. Can any body give the proper solution.
Thanks.
Posted

1 solution

you can use like this
C#
protected void Page_Init(object sender, EventArgs e)
       {
           try
           {
               DropDownList ddlParent =(DropDownList)Master.FindControl("ddlParent");
               if (ddlParent != null)
               {
                   ddlParent .SelectedIndexChanged += new EventHandler(lnkReferesh_Click);
               }
           }
           catch (Exception ex)
           {
               throw ex;
           }
       }


[Edit]:Set proper code block.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900