Click here to Skip to main content
Rate this: bad
good
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%" 
                    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 2-Feb-13 1:06am

1 solution

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

Solution 1

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

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

  Print Answers RSS
0 OriginalGriff 605
1 Maciej Los 319
2 BillWoodruff 184
3 Richard MacCutchan 180
4 Suraj Sahoo | Coding Passion 180
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2014
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