|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GridView, sorting, DataTable, and typing.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. 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." ok - thanks
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." > > 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. 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." > > 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."
How to access control in FormView
Launch a new browser window Creating N rows of controls ObjectDataSource ... could not find a non-generic method ... that has parameters: ... enable/disable text box based on dropdownlist via javascript post-back when the filename to upload changes How to add a dropdownlist to the column header in a GridView? Custom Web control question FormView/ItemTemplate - MultiView, Radio, & checkbox Overriding Calendar.CreateChildControls |
|||||||||||||||||||||||