Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FindControl to reference nested controls in gridview/listview

Reply
Thread Tools

FindControl to reference nested controls in gridview/listview

 
 
Martin
Guest
Posts: n/a
 
      02-07-2006
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>
</aspatalist>

Many hopeful regards,

Martin

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      02-07-2006
Hello Martin,

In this sample I have a DetailsView nested within a GridView which in turn
nested within a parent GridView.
http://www.webswapp.com/codesamples/...stedgridviews/

I access the controls within a GridView using the
GridView.SelectedRow.FindControl method. As for the datalist you would
access the controls using the DataListItemEventArgs.Item.FindControl as in
this sample:
http://www.societopia.net/Samples/Da...Hierarchy.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Martin" wrote:

> 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>
> </aspatalist>
>
> Many hopeful regards,
>
> Martin
>
>

 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      02-08-2006


On 7 Feb 2006 08:37:12 -0800, "Martin" <(E-Mail Removed)> wrote:

>
>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.

--
Scott
http://www.OdeToCode.com/blogs/scott/
 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      02-16-2006
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("GridV iew1"))

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

 
Reply With Quote
 
shivakalluri shivakalluri is offline
Junior Member
Join Date: Apr 2008
Posts: 2
 
      04-10-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Viewstate info instead of nested FindControl? John Kotuby ASP .Net 5 12-12-2007 04:34 PM
Collapsible Nested Datalists ? Findcontrol by Value? jobs ASP .Net 2 10-16-2006 10:05 PM
Custom Controls- Controls Collection-FindControl method Sundararajan ASP .Net Web Controls 2 03-10-2005 06:13 AM
findcontrol not getting reference to controls in datagrid footer james_crane@btinternet.com ASP .Net Web Controls 0 01-17-2005 02:26 PM
findcontrol to find in nested datalists Greg Fischer ASP .Net 2 11-16-2004 03:47 AM



Advertisments