Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to add dynamic controls in an asp table it works fine in asp.net as on pre-Init function of page I'm able to access asp table having dynamically added rows means that not null but same thing problem in sharepoint application page there everytime I'm getting asp:table object in pre_Init function of page as null. What's going wrong with this in sharepoint is there any setting for controls accessing viewstate in sharepoint application page. Also I tried all that dynamic controls generation in page_Load there I can access table object as all html loads at that time but I'm not able to get my dynamic controls values at that time all textboxes giving empty values samething in asp.net working fine and dynamic buttons event not firing first time click but fired on 2nd time click. This all scenario's working absolutely fine in asp.net but not in sharepoint application page.
in page markup file I have this control
<asp:Table runat="server" ID="tblBaseline">
and in code behind I'm doing:
protected void Page_PreInit(object sender, EventArgs e)
{
if(session["ProjID"]!=null)
{
LoadDynamicRows(int.parse(session["ProjID"].toString()));
}
}
private bool LoadDynamicRows(int ProjID)
{
tblBaseline.Rows.Clear();
TableRow tr;
TableCell tc;
TextBox tb;
Label lbl;
tr = new TableRow();
tc = new TableCell();
lbl = new Label();
lbl.Text = "StartDate";
tb = new TextBox();
tb.ID = ""; //should be Unique as setting from dt unique column
ajaxCal = new CalendarExtender();
ajaxCal.TargetControl = "";// textbox id
ajaxCal.PopUpControlID = ""; // an imagebuttonID should also be unique
tc.Controls.Add(lbl);
tc.Controls.Add(tb);
tc.Controls.Add(ajaxCal);
tr.Controls.Add(tc);
tblBaseline.Controls.Add(tr);
}

Please help me out from this headache.
Posted

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