Click here to Skip to main content
11,641,392 members (63,812 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
I m create a asp table

//.aspx page code

 <asp:Table ID="_tb" runat="server" style="border: 1px solid;" Width="80%" 
                    <asp:TableRow runat="server" BackColor="#3f3f3f">
                        <asp:TableCell Width="5%" style="color:white"><center>Sr No</center></asp:TableCell>
                        <asp:TableCell Width="30%" style="color:white"><center>Mid Station-Name</center></asp:TableCell>
                        <asp:TableCell Width="10%" style="color:white"><center>Status</center></asp:TableCell>

then i m creating dynamically rows and put some control in cells

//.cs page code

for (int i = 0; i < AllStat.Count; i++)

TableRow tr = new TableRow();
tr.Style.Add("border", "1px");
TableCell td1 = new TableCell();
td1.Attributes.Add("class", "cent");
TableCell td2 = new TableCell();
td2.Attributes.Add("class", "cent");
TableCell td3 = new TableCell();
td3.Attributes.Add("class", "cent");

td1.Text = (i + 1).ToString();

Label lb = new Label();
string[] splt = AllStat[i].Split(',');
lb.ID = splt[0];
lb.Text = splt[1].ToString();

DropDownList ddl = new DropDownList();
ddl.Items.Add(new ListItem("Select","0"));
for (int j = 0; j < AllStat.Count; j++)
ddl.Items.Add(new ListItem((j+1).ToString(),(j+10).ToString()));

but th problem is that i cant access any control that i created at run time..

when we count yhe rows in this table it return only "1" row every time that creating on .aspx page here i want to access dynamicall created dropdown list and label text..

Posted 2-Feb-13 0:06am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try to get your dynamically created table value in panel control.

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

  Print Answers RSS
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 185
4 Afzaal Ahmad Zeeshan 129

Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100