Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jan 20, 2014, 1:44 AM EST
public static Control DeepFindControl(Control c, string id)
{
if (c.ID == id)
{
return c;
}
if (c.HasControls)
{
Control temp;
foreach (var subcontrol in c.Controls)
{
temp = DeepFindControl(subcontrol, id);
if (temp != null)
{
return temp;
}
}
}
return null;
}
Or simply loop like,
var table = tblMyTable as HtmlTable;
string str;
for (int i = 0; i < table.Rows.Count; i++)
{
for (int j = 0; j < table.Rows[i].Cells.Count; j++)
{
// Use FindControl function here...
}
}
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jan 20, 2014, 1:06 AM EST
If you want to access the html control say table in aspx code behind, you have to use runat="server" attribute in the html table.
Example
....
On server side you can access it by using the variable tblMyTable
nishant ranjanRank #4,961 · 317 reputationPosted Jan 20, 2014, 1:19 AM EST
or say
i have control id and i want to know in which row number it exist.
nishant ranjanRank #4,961 · 317 reputationPosted Jan 20, 2014, 2:47 AM EST