473,405 Members | 2,379 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,405 software developers and data experts.

GridView in a GridView

Hi,
I have a gridView (grid1), which as a templateColumn.
In the template column, I have put in a gridView (grid2) and a
ObjectDataSource (objectDataSource2).

Question is... How to I pass the current_row_key of Grid1... to the
objectDataSource2 parameter?
(so that the second grid, gets only the information to do with current row
of grid1)
any help is deeply appreciated...

Thanks
Nalaka
Nov 19 '05 #1
6 3013
Hi Nalaka,

It's actually pretty simple once you grasp the concept. I can help you with
code if you want to try it. You have to use code--you can't specify the
DataSource declaritively (in the markup).

In the template column, add a Label (with the visible property set to
false). Bind that to the key. After you call DataBind() on the first
DataGrid, you loop through the first DataGrid's Items and use FindControl()
to get a reference to the child grid, and again to get a reference to the
label. Now, use your Label.Text to get the id and use that with your object
to get the DataSource for the child grid.

Some people don't catch on until they see it in action, but if you get it
let me know what type of DataSource you are using (DataSet, DataTable,
object) and I will give you a little bit of code.

Tim
"Nalaka" wrote:
Hi,
I have a gridView (grid1), which as a templateColumn.
In the template column, I have put in a gridView (grid2) and a
ObjectDataSource (objectDataSource2).

Question is... How to I pass the current_row_key of Grid1... to the
objectDataSource2 parameter?
(so that the second grid, gets only the information to do with current row
of grid1)
any help is deeply appreciated...

Thanks
Nalaka

Nov 19 '05 #2
Oops. I didn't read close enough. You are using 2.0 aren't you? There may
be an easier way in 2.0, I don't get it until next month!

If you want to do it the 1.1 way the concept should still work.

Tim
"Nalaka" wrote:
Hi,
I have a gridView (grid1), which as a templateColumn.
In the template column, I have put in a gridView (grid2) and a
ObjectDataSource (objectDataSource2).

Question is... How to I pass the current_row_key of Grid1... to the
objectDataSource2 parameter?
(so that the second grid, gets only the information to do with current row
of grid1)
any help is deeply appreciated...

Thanks
Nalaka

Nov 19 '05 #3
Hi Nalaka,

As for your question on displaying Nested GridView which has relation ships
between the binding datas. I think you can consider the following means:

We can put an invisible label or TextBox control in the templateField where
we'll also put the Nested GridView and sub DataSource control. Then, the
invisible Label or TextBox's Text property will be binded to parent
GridView's Key Column value(we can do this through IDEs' wizard ---- Edit
Template.....). After that, we configure the Sub DataSource control in the
template field, and add a control parameter for its "Where ...." sql
statement, and specify the invisible Label or Textbox as the control
source. Then, bind the nested GridView to the sub DataSource and run the
page, that'll display the nested GridViews we expected.

Actually I've tested with the NorthWind's Orders and OrderDetails tables
and works well.(I've even tested three level nested and also works :)).
However, one important things we need to take care, such template databound
control(GridView, DataList....) all store the binded datas in ViewState
which may make the page's size extremely huge. You'd take care of this to
see whether it's appropriate according to the target environment's network
bandwidth.

If there're anything unclear, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Nalaka" <na******@nospam.nospam>
| Subject: GridView in a GridView
| Date: Thu, 10 Nov 2005 16:07:27 -0800
| Lines: 17
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <es**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: m181-9.bctransit.bc.ca 199.60.181.9
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357227
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
| I have a gridView (grid1), which as a templateColumn.
| In the template column, I have put in a gridView (grid2) and a
| ObjectDataSource (objectDataSource2).
|
| Question is... How to I pass the current_row_key of Grid1... to the
| objectDataSource2 parameter?
| (so that the second grid, gets only the information to do with current
row
| of grid1)
|
|
| any help is deeply appreciated...
|
| Thanks
| Nalaka
|
|
|

Nov 19 '05 #4
Hi Tim,
Ok... I created a label (label_key) in the template field... and set the
value to outerGrid.key
(using Eval("key")).....
It works fine, now I can see the key in the inner template column.

Now the question is... I need to tell the "ObjectDataSource" of the
innerGrid (inside template field),
that the parameter is the text value of label_key.

at what point (which event), can I do this, and how do I do this......

yes... I can use your code sample....
Thanks
Nalaka


"timkling" <ti******@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hi Nalaka,

It's actually pretty simple once you grasp the concept. I can help you
with
code if you want to try it. You have to use code--you can't specify the
DataSource declaritively (in the markup).

In the template column, add a Label (with the visible property set to
false). Bind that to the key. After you call DataBind() on the first
DataGrid, you loop through the first DataGrid's Items and use
FindControl()
to get a reference to the child grid, and again to get a reference to the
label. Now, use your Label.Text to get the id and use that with your
object
to get the DataSource for the child grid.

Some people don't catch on until they see it in action, but if you get it
let me know what type of DataSource you are using (DataSet, DataTable,
object) and I will give you a little bit of code.

Tim
"Nalaka" wrote:
Hi,
I have a gridView (grid1), which as a templateColumn.
In the template column, I have put in a gridView (grid2) and a
ObjectDataSource (objectDataSource2).

Question is... How to I pass the current_row_key of Grid1... to the
objectDataSource2 parameter?
(so that the second grid, gets only the information to do with current
row
of grid1)
any help is deeply appreciated...

Thanks
Nalaka

Nov 19 '05 #5
Hello Steven, took some time for me to find this thear, but here I am =)

I have the same situation: a Gridview inside another Gridview. With the
difference is that I usually work from the codehind because I get some of
the info (XML mostly) from shared libraries. And I can debug it. And the
code is protected. Can this be done the same way? Gridview inside a gridview
from the codehind?

If not, tecnically I could use the datasource wizard since I could populate
all this gridview from a SQL connection, but I find this little problem: I
used the datasource wizard for the 'parent' gridview (never used it before).
All just fine, the test gives me back the records, etc, etc. But when I test
it, doesn't return any gridview at all =S

Didn't even start with the 'child' gridview...

Please, could you give me some help here? =$

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> escribió en el mensaje
news:oZ*************@TK2MSFTNGXA02.phx.gbl...
Hi Nalaka,

As for your question on displaying Nested GridView which has relation ships between the binding datas. I think you can consider the following means:

We can put an invisible label or TextBox control in the templateField where we'll also put the Nested GridView and sub DataSource control. Then, the
invisible Label or TextBox's Text property will be binded to parent
GridView's Key Column value(we can do this through IDEs' wizard ---- Edit
Template.....). After that, we configure the Sub DataSource control in the template field, and add a control parameter for its "Where ...." sql
statement, and specify the invisible Label or Textbox as the control
source. Then, bind the nested GridView to the sub DataSource and run the
page, that'll display the nested GridViews we expected.

Actually I've tested with the NorthWind's Orders and OrderDetails tables
and works well.(I've even tested three level nested and also works :)).
However, one important things we need to take care, such template databound control(GridView, DataList....) all store the binded datas in ViewState
which may make the page's size extremely huge. You'd take care of this to
see whether it's appropriate according to the target environment's network
bandwidth.

If there're anything unclear, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Nalaka" <na******@nospam.nospam>
| Subject: GridView in a GridView
| Date: Thu, 10 Nov 2005 16:07:27 -0800
| Lines: 17
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <es**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: m181-9.bctransit.bc.ca 199.60.181.9
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357227
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
| I have a gridView (grid1), which as a templateColumn.
| In the template column, I have put in a gridView (grid2) and a
| ObjectDataSource (objectDataSource2).
|
| Question is... How to I pass the current_row_key of Grid1... to the
| objectDataSource2 parameter?
| (so that the second grid, gets only the information to do with current
row
| of grid1)
|
|
| any help is deeply appreciated...
|
| Thanks
| Nalaka
|
|
|

Dec 5 '05 #6
Hi,
try this....
in the same templateField as inner GridView, put a invisible textbox above
the gridview.
use the text box eval("id") to bind to the outer grid.

set the inner grid view select parameter to the invisible textbox control
......

see if this works...
if not I have a more complicated work around that works for sure.
Only after doing that I realized that above may be much simpler.

Thanks
Nalaka


"Carlos Albert" <nadie@ningunlugar> wrote in message
news:ug***************@TK2MSFTNGP12.phx.gbl...
Hello Steven, took some time for me to find this thear, but here I am =)

I have the same situation: a Gridview inside another Gridview. With the
difference is that I usually work from the codehind because I get some of
the info (XML mostly) from shared libraries. And I can debug it. And the
code is protected. Can this be done the same way? Gridview inside a
gridview
from the codehind?

If not, tecnically I could use the datasource wizard since I could
populate
all this gridview from a SQL connection, but I find this little problem: I
used the datasource wizard for the 'parent' gridview (never used it
before).
All just fine, the test gives me back the records, etc, etc. But when I
test
it, doesn't return any gridview at all =S

Didn't even start with the 'child' gridview...

Please, could you give me some help here? =$

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> escribió en el mensaje
news:oZ*************@TK2MSFTNGXA02.phx.gbl...
Hi Nalaka,

As for your question on displaying Nested GridView which has relation

ships
between the binding datas. I think you can consider the following means:

We can put an invisible label or TextBox control in the templateField

where
we'll also put the Nested GridView and sub DataSource control. Then, the
invisible Label or TextBox's Text property will be binded to parent
GridView's Key Column value(we can do this through IDEs' wizard ---- Edit
Template.....). After that, we configure the Sub DataSource control in

the
template field, and add a control parameter for its "Where ...." sql
statement, and specify the invisible Label or Textbox as the control
source. Then, bind the nested GridView to the sub DataSource and run the
page, that'll display the nested GridViews we expected.

Actually I've tested with the NorthWind's Orders and OrderDetails tables
and works well.(I've even tested three level nested and also works :)).
However, one important things we need to take care, such template

databound
control(GridView, DataList....) all store the binded datas in ViewState
which may make the page's size extremely huge. You'd take care of this to
see whether it's appropriate according to the target environment's
network
bandwidth.

If there're anything unclear, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Nalaka" <na******@nospam.nospam>
| Subject: GridView in a GridView
| Date: Thu, 10 Nov 2005 16:07:27 -0800
| Lines: 17
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <es**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: m181-9.bctransit.bc.ca 199.60.181.9
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357227
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
| I have a gridView (grid1), which as a templateColumn.
| In the template column, I have put in a gridView (grid2) and a
| ObjectDataSource (objectDataSource2).
|
| Question is... How to I pass the current_row_key of Grid1... to the
| objectDataSource2 parameter?
| (so that the second grid, gets only the information to do with current
row
| of grid1)
|
|
| any help is deeply appreciated...
|
| Thanks
| Nalaka
|
|
|


Dec 5 '05 #7

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

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
1
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.