By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

GridView in a GridView

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.