|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
October 24th, 2006, 06:14 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
find all the controls inside any table
hi
how can I find all the controls inside any table
i.e.
<TABLE id="Table2">
<TR>
<TD>Country</TD>
<TD><asp:DropDownList id="listCountry" runat="server"></TD>
</TABLE>
..........I want to pick the list control I have tried
FindControl method
thx in adv
Amartya
|
October 24th, 2006, 06:35 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Run you table as a server control then do this:
For Each ctrl as control in Table.Controls
If TypeOf ctrl Is DropDownList then
//Do something
End if
Next
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
October 24th, 2006, 06:50 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
foreach (Control c in Table2.Controls)
{
Type t = c.GetType();
Response.Write( t.Name+" ");
}
this is my code and it gives
HtmlTableRow HtmlTableRow HtmlTableRow
but i need those server controls which i embded inside the table pls reply
|
October 24th, 2006, 06:54 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
is it possible!
because table is htmlcontrols & on the other hand textbox etc are WebControls??
|
October 24th, 2006, 06:56 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
actually i want ids of each server controls inside a table is it possible??
|
October 24th, 2006, 06:57 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
i dont see why its not possible, i do this all the time with tables and panels and never have a problem returning my webcontrols?
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
October 24th, 2006, 07:03 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have given my codes also made table2 runat=server
|
October 24th, 2006, 07:29 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
it's not working anyway thanks
|
October 24th, 2006, 08:04 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Make your loop recursive;
private void tableControls(){
//This is your main loop
foreach(Control c in Table.Controls){
checkControls(c);
}
}
private void checkControls(Control crl){
//This method can be recursive
if ((crl.GetType() == DropDownList)) {
//do something
}
else if ((crl.Controls.Count > 0)) {
foreach (Control c in crl.Controls) {
checkControls(c);
}
}
}
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
October 24th, 2006, 08:22 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks a lot it's working
|
|
|