473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

FindControl to reference nested controls in gridview/listview

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

Feb 7 '06 #1
3 19316
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>
</asp:Datalist>

Many hopeful regards,

Martin

Feb 7 '06 #2


On 7 Feb 2006 08:37:12 -0800, "Martin" <mr****@hotmail.com> 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/
Feb 8 '06 #3
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

Feb 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marco Martin | last post by:
Hi, I have a control that nests other controls. I need to be able to get a handle on these controls when clicked. the problem is that when I click on one of the nested controls, my mouse down...
1
by: Rea Peleg | last post by:
Hi all I need to reference web form (server side) controls, inside client side javascript, in order to enable some of them according to some condition. I tried referencing through...
0
by: TJS | last post by:
Is there a way to share objects between nested controls ? i want to reset the user's droplist selection, for a css style sheet change, to their choice. the problem ================== The...
1
by: SouthSpawn | last post by:
I have a datagrid with a checkbox column, and dropdown list that does a autopostback. Basically, the dropdown list is a filter for the datagrid. Here is my workflow. 1. Load .aspx page. 2....
2
by: nulldevice | last post by:
I've got a datagrid with some nested controls, created at design-time. The controls themselves have no databound values. After a few other operations on the page (selecting a few parameters,...
1
by: humbleFunGuy | last post by:
What does nested controls mean in .Net? Any help is appreciated. Thanks, fanzi
14
by: 97T | last post by:
Well this is still bugging me. I know there are other ways around this, but for a number of reasons I would like to be able to do this one simple thing. I have a form with a number of controls...
3
by: garyusenet | last post by:
I want to disable all controls on form barring two buttons. I have about 20 controls. Is there a way I can reference all controls on the form in one go? So I could then do something like.. ...
0
by: Chris | last post by:
I have a formview that contains a "drill down" set of dropdowns. You select a team and it filters the team members drop down to show team members who belong to that team. I am acheiving this by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.