How to create a class that can be used like a DataTable?
-
I'm looking for the way to create a class that can be used like a DataTable. I just want to have the dynamic rows and columns (no need to have AcceptChanges or Rollback or etc).. but that class should be able to bind with DataGrid. Thanks.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
I'm looking for the way to create a class that can be used like a DataTable. I just want to have the dynamic rows and columns (no need to have AcceptChanges or Rollback or etc).. but that class should be able to bind with DataGrid. Thanks.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Michael Sync wrote:
I'm looking for the way to create a class that can be used like a DataTable. I just want to have the dynamic rows and columns (no need to have AcceptChanges or Rollback or etc).. but that class should be able to bind with DataGrid.
You can try inheriting the DataTable to write one...? But what's wrong using the DataTable directly... as long as you want to keep it binded with a DataSet..?
Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV
-
Michael Sync wrote:
I'm looking for the way to create a class that can be used like a DataTable. I just want to have the dynamic rows and columns (no need to have AcceptChanges or Rollback or etc).. but that class should be able to bind with DataGrid.
You can try inheriting the DataTable to write one...? But what's wrong using the DataTable directly... as long as you want to keep it binded with a DataSet..?
Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV
Thanks. Actually, I'm using Prism (CompositeWPF) version 2 with multi-targeting feature. Once we crate a class, we have to think about how to use in both WPF and Silverlight. DataTable or DataSet or etc is not available in Silverlight. So, I'm thinking to create very small version of DataTable that we can add/remove the column with Columns name. And we want to bind it with DataGird.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Thanks. Actually, I'm using Prism (CompositeWPF) version 2 with multi-targeting feature. Once we crate a class, we have to think about how to use in both WPF and Silverlight. DataTable or DataSet or etc is not available in Silverlight. So, I'm thinking to create very small version of DataTable that we can add/remove the column with Columns name. And we want to bind it with DataGird.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Michael Sync wrote:
I'm thinking to create very small version of DataTable that we can add/remove the column with Columns name
Well, in that case, you might need to write a simple and small version of DataTable for ur ViewModel. You can make use of reflector to get more idea about the .net implementation of DataTable. One suggestion though, if the binding is the only concern, you could actually define any .net enumerable properties ..I guess?
Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV
-
Michael Sync wrote:
I'm thinking to create very small version of DataTable that we can add/remove the column with Columns name
Well, in that case, you might need to write a simple and small version of DataTable for ur ViewModel. You can make use of reflector to get more idea about the .net implementation of DataTable. One suggestion though, if the binding is the only concern, you could actually define any .net enumerable properties ..I guess?
Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV
Yes. I'm thinking to have a class like below. class MyDataRow{ } class MyDataColumn{ } class MyDataTable{ List Rows{} List Columns{} } but 1) I'm not sure whether how I can make my class as a binding class. eg. VM public MyDataTable MyData{ set{.. ....PropertyChanged(..).... } get{..} } 2. How can I know whether new column or row has been added to now?? E.g. MyDataTable mydata = new MyDataTable(); mydata.Columns.Add(new MyDataColumn() { Name = "A" }); mydata.Columns.Add(new MyDataColumn() { Name = "B" }); mydata.Columns.Add(new MyDataColumn() { Name = "C" }); Thanks in advance.
-
Yes. I'm thinking to have a class like below. class MyDataRow{ } class MyDataColumn{ } class MyDataTable{ List Rows{} List Columns{} } but 1) I'm not sure whether how I can make my class as a binding class. eg. VM public MyDataTable MyData{ set{.. ....PropertyChanged(..).... } get{..} } 2. How can I know whether new column or row has been added to now?? E.g. MyDataTable mydata = new MyDataTable(); mydata.Columns.Add(new MyDataColumn() { Name = "A" }); mydata.Columns.Add(new MyDataColumn() { Name = "B" }); mydata.Columns.Add(new MyDataColumn() { Name = "C" }); Thanks in advance.
You may want to look here http://msdn.microsoft.com/en-us/library/ms752347.aspx[^] Couldn't your problem be solved by using a WebService or WCF to expose the necessary data?
only two letters away from being an asset
-
You may want to look here http://msdn.microsoft.com/en-us/library/ms752347.aspx[^] Couldn't your problem be solved by using a WebService or WCF to expose the necessary data?
only two letters away from being an asset
No. WCF team can give only the list of column that I need to show on the DataGird and the data that I need to populate to the DataGrid. Thanks.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
No. WCF team can give only the list of column that I need to show on the DataGird and the data that I need to populate to the DataGrid. Thanks.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
I'm sorry, am I missing something? You can get the data and the columns, isn't that what a DataTable defines also. You get the data in an XML format, or even a collection of some sort, and bind it to the grid. I'm just not seeing your problem I guess.
only two letters away from being an asset