Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > "parent / child" datagrids

Reply
Thread Tools

"parent / child" datagrids

 
 
Danny Sikora
Guest
Posts: n/a
 
      02-11-2005
Hello,

I have a datagrid on a .aspx page, and another datagrid on a .ascx page. My
goal is to populate the "child" datagrid (the one from the control) depending
on the selected index of the parent datagrid. The child control gets the
DataKeyField of the selected index of the datagrid from the parent page to
use to populate it's datagrid.

So, when I call a sort, edit, or whatever from the child datagrid, it fires
a postback to the parent page, and so I have to reload the control in the
page_load area of of the parent page....fine so far.

My problem comes when I select a new item from the parent datagrid. The
page posts back, and then it reloads my child control, but it still has the
ID from the previously selected Item because it reloads the control before it
fires the DataGrid.OnSelectCommand function.

I tried to clear the placeholder that I load the control into, and reload
the control. This sort-of works...at this point there is 2 controls (one
loaded from page_load, and one from the selected index changed), but only one
is visible.

Is there a way to actually DELETE or UNLOAD a control from the page or
placeholder, and actually reload it, as opposed to the placeHolder.Clear()
function.

Thanks,

Danny
 
Reply With Quote
 
 
 
 
Roy
Guest
Posts: n/a
 
      02-12-2005
Hey Danny, thanks for replying in my thread. I had actually already
given the always posting back a try, but it's...not doing what it
should. Long story. I'll figure it out sooner or later. Though if you
get the chance, take a look at this thread:

http://groups-beta.google.com/group/...eca62f5ce552c7

It's my latest little error, and I strongly suspect you may have some
insight...

But enough about me, on to your error. Reading your post above makes me
realize once again how many different ways there are to code the same
thing. We're coming at it from completely different angles. For
instance, I don't use the datakeyfield or selected index properties
anywhere in my code. Here's what I do, in my .aspx page I have my
template column containing my nested datagrid/user control. NOTE my
setting of variables below. I'm "linking" the two thusly.

<asp:TemplateColumn><ItemTemplate>
<tr><td colspan="9">
<UC_Grid:Nested id="FVDGrid" x=<%# container.dataitem("vown")%> y=<%#
container.dataitem("van_no")%> runat="server" />
</td></tr>
</ItemTemplate></asp:TemplateColumn>

Then in my .ascx page I declare x and y and then use them to set my
sqlcommand's variables which gets passed to a stored proc. Observe:

With FVDCommand
..CommandType = CommandType.StoredProcedure
..Parameters.Add (New SqlParameter("@x", SqlDbType.nvarchar,50)).Value =
x
..Parameters.Add (New SqlParameter("@y", SqlDbType.nvarchar,50)).Value =
y
End With

Simple. Easy. No fuss.

Good luck!

 
Reply With Quote
 
 
 
 
Roy
Guest
Posts: n/a
 
      02-12-2005
Hey Danny, thanks for replying in my thread. I had actually already
given the always posting back a try, but it's...not doing what it
should. Long story. I'll figure it out sooner or later. Though if you
get the chance, take a look at this thread:

http://groups-beta.google.com/group/...eca62f5ce552c7

It's my latest little error, and I strongly suspect you may have some
insight...

But enough about me, on to your error. Reading your post above makes me
realize once again how many different ways there are to code the same
thing. We're coming at it from completely different angles. For
instance, I don't use the datakeyfield or selected index properties
anywhere in my code. Here's what I do, in my .aspx page I have my
template column containing my nested datagrid/user control. NOTE my
setting of variables below. I'm "linking" the two thusly.

<asp:TemplateColumn><ItemTemplate>
<tr><td colspan="9">
<UC_Grid:Nested id="FVDGrid" x=<%# container.dataitem("vown")%> y=<%#
container.dataitem("van_no")%> runat="server" />
</td></tr>
</ItemTemplate></asp:TemplateColumn>

Then in my .ascx page I declare x and y and then use them to set my
sqlcommand's variables which gets passed to a stored proc. Observe:

With FVDCommand
..CommandType = CommandType.StoredProcedure
..Parameters.Add (New SqlParameter("@x", SqlDbType.nvarchar,50)).Value =
x
..Parameters.Add (New SqlParameter("@y", SqlDbType.nvarchar,50)).Value =
y
End With

Simple. Easy. No fuss.

Good luck!

 
Reply With Quote
 
Roy
Guest
Posts: n/a
 
      02-12-2005
Hey Danny, thanks for replying in my thread. I had actually already
given the always posting back a try, but it's...not doing what it
should. Long story. I'll figure it out sooner or later. Though if you
get the chance, take a look at this thread:

http://groups-beta.google.com/group/...eca62f5ce552c7

It's my latest little error, and I strongly suspect you may have some
insight...

But enough about me, on to your error. Reading your post above makes me
realize once again how many different ways there are to code the same
thing. We're coming at it from completely different angles. For
instance, I don't use the datakeyfield or selected index properties
anywhere in my code. Here's what I do, in my .aspx page I have my
template column containing my nested datagrid/user control. NOTE my
setting of variables below. I'm "linking" the two thusly.

<asp:TemplateColumn><ItemTemplate>
<tr><td colspan="9">
<UC_Grid:Nested id="FVDGrid" x=<%# container.dataitem("vown")%> y=<%#
container.dataitem("van_no")%> runat="server" />
</td></tr>
</ItemTemplate></asp:TemplateColumn>

Then in my .ascx page I declare x and y and then use them to set my
sqlcommand's variables which gets passed to a stored proc. Observe:

With FVDCommand
..CommandType = CommandType.StoredProcedure
..Parameters.Add (New SqlParameter("@x", SqlDbType.nvarchar,50)).Value =
x
..Parameters.Add (New SqlParameter("@y", SqlDbType.nvarchar,50)).Value =
y
End With

Simple. Easy. No fuss.

Good luck!

 
Reply With Quote
 
Roy
Guest
Posts: n/a
 
      02-12-2005
I have no clue why there are two messages from me with exclamation
marks... darn google groups...

Hey, when we are both done with our projects, care to swap code? I'm
planning on learning C# in a few months anyhow, so the code would be a
nice introduction.

 
Reply With Quote
 
Danny Sikora
Guest
Posts: n/a
 
      02-14-2005
Sorry Can't - I'd get fired.

"Roy" wrote:

> I have no clue why there are two messages from me with exclamation
> marks... darn google groups...
>
> Hey, when we are both done with our projects, care to swap code? I'm
> planning on learning C# in a few months anyhow, so the code would be a
> nice introduction.
>
>

 
Reply With Quote
 
Roy
Guest
Posts: n/a
 
      02-16-2005
How so?

A million folks the world over must've cranked out a million identical
projects. I work for as a contractor for the US Military and routinely
trade (and post) code online. It's all good. Unless your employer has
applied for a patent (which would be quite impossible in the case of
nested datagrids), it's your code to do with as you wish.

 
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
Checkboxes with Repeaters and DataGrids Fresh Air Rider ASP .Net 0 03-05-2004 10:12 PM
Datagrids Abul Hasan ASP .Net 1 10-13-2003 03:39 AM
TabIndex of DataGrids Ravikanth[MVP] ASP .Net 2 07-21-2003 04:09 PM
Nested DataGrids Dave ASP .Net 1 07-15-2003 05:03 PM
Re: Nested Datagrids Juliano Bortolozzi ASP .Net 0 07-14-2003 05:28 PM



Advertisments