PC Review


Reply
Thread Tools Rate Thread

cast datagrid.datasource to dataset (datasource is table)

 
 
newsgroper@yahoo.com
Guest
Posts: n/a
 
      3rd Jul 2003
I extended a windows datagrid to some formatting and to add controls
like buttons and comboboxes. To get the datagrid to accept the
changes I add tablestyles. To make the datagrid use the new
tablestyles and bind to the table I used the following code...

this.TableStyles.Clear();
this.TableStyles.Add(_tableStyle);
this.DataSource = ((DataSet)this.DataSource).Tables[tableName];

Everything works great! However, now my form needs to access the
grids datasource as a dataset like so...

theDataSet.Update((DataSet)theGrid.DataSource);

Unfortunately, I get an invalid cast exception since the datasource is
a datatable. Can anyone give me suggestions so I can update the
dataset that was originally bound to my grid? I know the problem is
because I bound the table to the grid (within the grid's code) when I
extended the grid. I am just not sure how to get the datasource back
to a dataset.
 
Reply With Quote
 
 
 
 
Palo Mraz
Guest
Posts: n/a
 
      4th Jul 2003
> theDataSet.Update((DataSet)theGrid.DataSource);
DataSet doesn't expose Update method. What is the type of the theDataSet
variable?

A solution seems to be simple (maybe I don't understand you explanation:-):

theDataSet.Update(((DataTable)theGrid.DataSource).DataSet)

Palo
http://www.vbinfozine.com - Real world entertaining information for Visual
Basic developers



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
InvalidCastException: (DataSet) DataGrid.DataSource =?Utf-8?B?TmFk?= Microsoft Dot NET Framework Forms 3 22nd Apr 2005 02:58 PM
pls help: how can i select a just inserted row in a datagrid (using a dataset as datasource)? Juan Microsoft C# .NET 2 8th Nov 2004 02:36 PM
pls help: how can i select a just inserted row in a datagrid (using a dataset as datasource)? Juan Microsoft Dot NET 0 8th Nov 2004 12:58 PM
Datagrid Datasource (Dataset , Dataview vs Datareader) Al Microsoft Dot NET 1 31st Dec 2003 12:02 AM
selecting DataSource of a DataGrid when the dataset is in a different form? Sam74 Microsoft C# .NET 2 13th Sep 2003 05:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:34 AM.