TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
d developer
NA
13
4.2k
How to find child controls in asp.net dynamically
Jun 4 2015 3:02 PM
Hi,
My table rows and cells created dynamically in c#. I need to find a control based on id.
< <form id="form1" runat="server>
<asp:Table id="table" runat="server">
</asp:Table>
</form>
C#
for (int row = 0; row < 10; row++)
{
TableRow tr= new TableRow();
tr.ID = string.Format("tr_{0}", row);
for (int cell = 0; cell < 4; cell++)
{
TableCell tc= new TableCell();
tc.ID = string.Format("tc_{0}{1}", row, cell);
}
table.Rows.Add(tc);
protected void Button_Click(object sender, EventArgs e)
{
foreach (TableRow tr in tblDynamic.Rows)
{
HyperLink hl = this.FindControl("form1$table$tr_0$tc_03$hypAssign0") as HyperLink;
tr.Cells[3].Controls.Remove(hl);
}
}
On the above highlighted I could just remove a hyperlink for row 0 and tablecell 3. I need to make dynamic, in that way it removes the hyperlink if I click row 5 or so on so forth.. Right now I hardcoded but hwo to make that tr_0 as tr_i or something for each row selected and tc_03 something dynamic?
Reply
Answers (
5
)
Timer for Online Exam in ASP.NET
Datagridview to excel