FindControl to reference nested controls in gridview/listview

M

Martin

Hi,

I have a very frustrating problem that I have researched for countless
hours to no avail. There are many posts asking very similar things,
however none usefull in my situation. I am using VS 2005 (ASP 2.0) and
VB .NET.

I have a page with a datalist, a gridview and then other data controls,
nested in that order. This all works great, and produces a nice looking
page, but I cannot for the life of me figure out how to reference
controls on the nested gridview and formviews. The HTML page is similar
to the below. What would be the correct syntaxt for referencing a
control on eg. FormView1 from Visual Basic code-behind? How does that
differ to a control on GridView2?

Can anyone point me in the right direction here? Perhaps a tutorial
that discusses these cases? I can post the actual code here, but I
thought the summary would be more meaningful.

<asp:datalist>
<asp:GridView ID="GridView1">
<asp:Boundfield> </asp:BoundField>
<asp:Boundfield> </asp:BoundField>
<asp:TemplateField>
<asp:label ID="outerGridID">
<asp:GridView ID="GridView2">
</asp:GridView>
<asp:Repeater ID="Repeater1">
</asp:Repeater>
<asp:FormView ID="FormView1">
</asp:FormView>
</asp:TemplateField>
</asp:GridView>
</asp:Datalist>

Many hopeful regards,

Martin
 
S

Scott Allen

Can anyone point me in the right direction here? Perhaps a tutorial
that discusses these cases? I can post the actual code here, but I
thought the summary would be more meaningful.

Hi Martin:

I have a tutorial on using FindControl written here:

http://odetocode.com/Articles/116.aspx


Although the article doesn't specifically talk about FormViews and
GridViews, the concepts are the same. Most importantly, understanding
where an INamingContainer exists. I hope you find it helpful.
 
M

Martin

Hi Phillip and Scott,

Many thanks for your help - I think there may be some basic concepts I
am having trouble with. I thought I might have to do a nested
FinControl, similar to:

DataList1.FindControl(GridView1.FindControl("GridView1"))

But I think CTYPE might be a clue to me.... I will dig into the
examples given and hopefully that will bring be closer to the answer.

Regards,

Martin
 
Joined
Apr 9, 2008
Messages
2
Reaction score
0
How to export the above gridview to excel..???

HI all,

I'm looking for the same kind of expandable girdview.
Thanks for the one u mentioned above.

Another issue I have is I need to export this gridview to excel along with the child gridviews.
If it is possible, please help me in this issue.

Thanks in advance.

Shiva
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top