"parent / child" datagrids

D

Danny Sikora

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
 
R

Roy

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...r=recent&&_doneTitle=Back&&d#13eca62f5ce552c7

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!
 
R

Roy

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...r=recent&&_doneTitle=Back&&d#13eca62f5ce552c7

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!
 
R

Roy

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...r=recent&&_doneTitle=Back&&d#13eca62f5ce552c7

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!
 
R

Roy

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

Roy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top