|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
"parent / child" datagridsI 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 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/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/238f3d72044da12f/13eca62f5ce552c7?_done=%2Fgroup%2Fmicrosoft.public.dotnet.framework.aspnet%2Fthreads%3Fstart%3D30%26order%3Drecent%26&_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! 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. Sorry Can't - I'd get fired.
Show quoteHide quote "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. > > 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. 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/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/238f3d72044da12f/13eca62f5ce552c7?_done=%2Fgroup%2Fmicrosoft.public.dotnet.framework.aspnet%2Fthreads%3Fstart%3D30%26order%3Drecent%26&_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! 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/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/238f3d72044da12f/13eca62f5ce552c7?_done=%2Fgroup%2Fmicrosoft.public.dotnet.framework.aspnet%2Fthreads%3Fstart%3D30%26order%3Drecent%26&_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!
Datagrid ... pain .... HELP!
Problem with datagrid update CancelCommand Not Firing! problem updating in datagrid ?? How to refresh a parent grid? Set column names to template grid at runtime Datagrid Footer now showing up correctly selection of fields in datatable for Datagrid Hyperlink Column Event Handler... Dynamically adding DataGrid columns |
|||||||||||||||||||||||