Home All Groups Group Topic Archive Search About

GridView, sorting, DataTable, and typing.

Author
19 Mar 2006 10:26 PM
David Thielen
Hi;

If I want my GridView to support sorting it says I must return a DataTable
instead of a collection. Doesn’t this mean that when I select a row it will
then give that FormView a DataRow? This will make everything un-typed which I
don’t like. Is there any way around this?

With a collection (what I now have) each "row" is a class I created where
the data is in properties that are all typed so everything is strongly typed.
What I would prefer is that I can keep returning a collection so I keep the
strong typing.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Author
20 Mar 2006 6:41 AM
Kevin Yu [MSFT]
Hi dave,

What do you mean by "selecting" a row? Are you working on a windows form
DataGridView or an ASP.NET datagrid?

If WinForm, do you want to return a certain type of object from selecting a
row of the DataGridView? If so, no, we cannot get that object. You can only
get a DataRow or DataRowView from the CurrencyManager. You have to get data
from that row and fill them into that class object manually. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Author
20 Mar 2006 3:00 PM
David Thielen
ok - thanks

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



Show quoteHide quote
"Kevin Yu [MSFT]" wrote:

> Hi dave,
>
> What do you mean by "selecting" a row? Are you working on a windows form
> DataGridView or an ASP.NET datagrid?
>
> If WinForm, do you want to return a certain type of object from selecting a
> row of the DataGridView? If so, no, we cannot get that object. You can only
> get a DataRow or DataRowView from the CurrencyManager. You have to get data
> from that row and fill them into that class object manually. HTH.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
>
Author
20 Mar 2006 3:47 PM
David Thielen
One follow-up question. One of my columns has a value of 0 or 1. But I do not
what to show 0 or 1 to the user - I want to show "XML" or "SQL". How can I do
that when returning a DataTable?

The best I have come up with is I do my own select, read with a
DbDataReader, and then build up a DataTable from the reader results.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



Show quoteHide quote
"Kevin Yu [MSFT]" wrote:

> Hi dave,
>
> What do you mean by "selecting" a row? Are you working on a windows form
> DataGridView or an ASP.NET datagrid?
>
> If WinForm, do you want to return a certain type of object from selecting a
> row of the DataGridView? If so, no, we cannot get that object. You can only
> get a DataRow or DataRowView from the CurrencyManager. You have to get data
> from that row and fill them into that class object manually. HTH.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
>
Author
21 Mar 2006 2:18 AM
Kevin Yu [MSFT]
Yes, Dave. You have to create another DataTable which stores the display
data "XML" or "SQL". Create a DataRelation between the parent table and
child table. You will have to write additional code to have the column
display the string data.

Another option is to create an expression column. The column value is
caculated dynamically according to other columns. Please check the
DataColumn.Expression property for more information:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatadatacolumnclassexpressiontopic.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."