Nested DataGrid using Relations sorting child

G

Guest

I have a Nested Datagrid that is using a data relations to tie the parent
child datagrids together. All is working well with the display but I am
having some issues trying to sort the child datagrid.

HTML
Datagrid1
TemplateColumn
Table
Header information
Detail Information
DataGrid2 - AllowSorting=true, DataKeyField="CUSTOMERPARTID"

aspx.cs:
DataGrid2_SortCommand
DataGrid NestedDataGrid = (DataGrid) source;
DataView NestedView = (DataView) NestedDataGrid.DataSource;
NestedView.Sort=strSort;
NewDataGrid.DataSource = NestedView;
NewDataGrid.DataKeyField = "CUSTOMERPARTID";
NewDataGrid.DataBind();

When I map the NestedView to an outside Datagrid the sorting works fine but
when I am trying to bind the NestedView to the Child Datagrid it clears out
the child records in the datagrid. What I noticed was that, binding the
child datagrid with the new sorted view the DataKeyArray gets cleared out.

Any help would be great.

Thanks,
 
S

Steven Cheng[MSFT]

Hi DelphiBlue,

Welcome to MSDN newsgroup.
From your description, you're using nested datagrids in your asp.net page
to display master/details datas. However, you found that you got problems
when apply sorting function on the nested inner datagrid , yes?

Based on the symtpom and the code sinppet you provided, I think the problem
is likely caused by the "NestedView" you used in the

DataGrid2_SortCommand


function. In DataGrid2_SortCommand you retrieve the "NestedView" from the
(DataView) NestedDataGrid.DataSource;

However, the NestedDataGrid's DataSource is only available during the
databinding processing time. So in the Sorting postback event, that
property is not availble, so you bind a empty(null) datasource to your
nestegrid which cause the nestedgrid displaying empty data.

For your scenario, generally, we'll need to put the DataSource for
master/details datagrid in a certain persistent storage, for example, the
asp.net 's application Cache or Session State. So when there occurs
postback events which need to rebind the data, we can retrieve the
dataset/datatable from them and create the certain Dataview from the stored
dataobjects.

In addition, you can also requery the data from database in each postback
sorting event, though this will add perfomance pain on the database but
will release your serverside memory (for session or application cache 's
memory usage).

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





--------------------
| Thread-Topic: Nested DataGrid using Relations sorting child
| thread-index: AcXE53aJgoDi/8/RTP+FggmE576dvA==
| X-WBNR-Posting-Host: 68.20.140.7
| From: "=?Utf-8?B?RGVscGhpQmx1ZQ==?=" <[email protected]>
| Subject: Nested DataGrid using Relations sorting child
| Date: Thu, 29 Sep 2005 04:18:05 -0700
| Lines: 32
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50937
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| I have a Nested Datagrid that is using a data relations to tie the parent
| child datagrids together. All is working well with the display but I am
| having some issues trying to sort the child datagrid.
|
| HTML
| Datagrid1
| TemplateColumn
| Table
| Header information
| Detail Information
| DataGrid2 - AllowSorting=true, DataKeyField="CUSTOMERPARTID"
|
| aspx.cs:
| DataGrid2_SortCommand
| DataGrid NestedDataGrid = (DataGrid) source;
| DataView NestedView = (DataView) NestedDataGrid.DataSource;
| NestedView.Sort=strSort;
| NewDataGrid.DataSource = NestedView;
| NewDataGrid.DataKeyField = "CUSTOMERPARTID";
| NewDataGrid.DataBind();
|
| When I map the NestedView to an outside Datagrid the sorting works fine
but
| when I am trying to bind the NestedView to the Child Datagrid it clears
out
| the child records in the datagrid. What I noticed was that, binding the
| child datagrid with the new sorted view the DataKeyArray gets cleared out.
|
| Any help would be great.
|
| Thanks,
|
|
|
|
 
S

Steven Cheng[MSFT]

Hi DelphiBlue,

How are you doing on this issue, have you got any progress? If there're
anything else we can help, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
--------------------
| X-Tomcat-ID: 112481911
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 30 Sep 2005 07:28:45 GMT
| Subject: RE: Nested DataGrid using Relations sorting child
| X-Tomcat-NG: microsoft.public.dotnet.general
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.general
| Lines: 94
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:51022
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi DelphiBlue,
|
| Welcome to MSDN newsgroup.
| From your description, you're using nested datagrids in your asp.net
page
| to display master/details datas. However, you found that you got problems
| when apply sorting function on the nested inner datagrid , yes?
|
| Based on the symtpom and the code sinppet you provided, I think the
problem
| is likely caused by the "NestedView" you used in the
|
| DataGrid2_SortCommand
|
|
| function. In DataGrid2_SortCommand you retrieve the "NestedView" from
the
| (DataView) NestedDataGrid.DataSource;
|
| However, the NestedDataGrid's DataSource is only available during the
| databinding processing time. So in the Sorting postback event, that
| property is not availble, so you bind a empty(null) datasource to your
| nestegrid which cause the nestedgrid displaying empty data.
|
| For your scenario, generally, we'll need to put the DataSource for
| master/details datagrid in a certain persistent storage, for example, the
| asp.net 's application Cache or Session State. So when there occurs
| postback events which need to rebind the data, we can retrieve the
| dataset/datatable from them and create the certain Dataview from the
stored
| dataobjects.
|
| In addition, you can also requery the data from database in each postback
| sorting event, though this will add perfomance pain on the database but
| will release your serverside memory (for session or application cache 's
| memory usage).
|
| 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.)
|
|
|
|
|
| --------------------
| | Thread-Topic: Nested DataGrid using Relations sorting child
| | thread-index: AcXE53aJgoDi/8/RTP+FggmE576dvA==
| | X-WBNR-Posting-Host: 68.20.140.7
| | From: "=?Utf-8?B?RGVscGhpQmx1ZQ==?=" <[email protected]>
| | Subject: Nested DataGrid using Relations sorting child
| | Date: Thu, 29 Sep 2005 04:18:05 -0700
| | Lines: 32
| | Message-ID: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Newsgroups: microsoft.public.dotnet.general
| | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50937
| | X-Tomcat-NG: microsoft.public.dotnet.general
| |
| | I have a Nested Datagrid that is using a data relations to tie the
parent
| | child datagrids together. All is working well with the display but I
am
| | having some issues trying to sort the child datagrid.
| |
| | HTML
| | Datagrid1
| | TemplateColumn
| | Table
| | Header information
| | Detail Information
| | DataGrid2 - AllowSorting=true, DataKeyField="CUSTOMERPARTID"
| |
| | aspx.cs:
| | DataGrid2_SortCommand
| | DataGrid NestedDataGrid = (DataGrid) source;
| | DataView NestedView = (DataView) NestedDataGrid.DataSource;
| | NestedView.Sort=strSort;
| | NewDataGrid.DataSource = NestedView;
| | NewDataGrid.DataKeyField = "CUSTOMERPARTID";
| | NewDataGrid.DataBind();
| |
| | When I map the NestedView to an outside Datagrid the sorting works fine
| but
| | when I am trying to bind the NestedView to the Child Datagrid it clears
| out
| | the child records in the datagrid. What I noticed was that, binding
the
| | child datagrid with the new sorted view the DataKeyArray gets cleared
out.
| |
| | Any help would be great.
| |
| | Thanks,
| |
| |
| |
| |
|
|
 

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

Top