Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m create a asp table

//.aspx page code

ASP.NET
<asp:Table ID="_tb" runat="server" style="border: 1px solid;" Width="80%"
                   GridLines="Both">
                   <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>
                   </asp:TableRow>
               </asp:Table>



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();
tr.Cells.Add(td1);

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

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()));
}
td3.Controls.Add(ddl);
tr.Cells.Add(td3);
_tb.Rows.Add(tr);
}

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..


thanks.
Posted

1 solution

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

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