Click here to Skip to main content
12,953,491 members (51,979 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
ppolymorphe 2,020
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2017
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