Hi all
I am deriving my class from a webpart and adding my own methods to it by passing some variables to the constructor. The custom webpart is responsible to create some dynamic controls based on the database values, say for example populating a RadGrid.
In my aspx page, I have added some code in the Page_Init method to create the dynamic WebPartZone and I am creating the instance of my custom webpart class and adding it to the WebPartManager1. (I've placed the WebPartManager on the aspx page)
sample.ascx.cs file
-------------------
protected void Page_Init(object sender, EventArgs e){
if ((!IsPostBack)){
WPZone2 = new WebPartZone();WPZone2.ID = "WPZ";RadAjaxPanel1.Controls.Add(WPZone2);
}
}
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack) {WebPartClass AddWP = new WebPartClass();WebPartManager1.AddWebPart(AddWP, WebPartZone1, 0);
}
}
webpart.cs file
---------------
public class WebPartClass : WebPart
{
public WebPartClass()
{
RadGrid Rg = new RadGrid();
Rg.AutoGenerateColumns = false;
Rg.AllowSorting = true;
this.Title = "Study Grid";
Rg.AllowPaging = true;
Rg.ID = "Radgrids";
Rg.DataSource = RetriveValues();
Rg.DataBind();
this.Controls.Add(Rg);
}
}
When i run the above program,the webpart with radgrid, loads properly in the UI.
The webpartzone is not visible in the Postback.
How do I persist the state of dynamic webpartzone?
Thanks,Uma.