hamid Posted April 19, 2006 Posted April 19, 2006 i have a datagrid with following code this.dataSet11.Clear(); this.oleDbDataAdapter1.Fill(this.dataSet11,"ClientsTable"); this.dataGrid1.DataSource=this.dataSet11.Tables["ClientsTable"].DefaultView; DataTable dataTable = (DataTable)dataGrid1.DataSource;but app return error when try this line: DataTable dataTable = (DataTable)dataGrid1.DataSource; why? i want this code for autoresize DataGrid, so let me know if you have a correct code for autoresizing datagrid. ;) Quote [ once4ever ]
Administrators PlausiblyDamp Posted April 19, 2006 Administrators Posted April 19, 2006 Does it make a difference if you set the data source to the table rather than the table's default view? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
hamid Posted April 19, 2006 Author Posted April 19, 2006 there is'nt DataSource properties for table object! but i remove default view and it done. this.dataSet11.Clear(); this.oleDbDataAdapter1.Fill(this.dataSet11,"ClientsTable"); this.dataGrid1.DataSource=this.dataSet11.Tables["ClientsTable"]; DataTable dataTable = (DataTable)dataGrid1.DataSource; thank you Quote [ once4ever ]
*Experts* Nerseus Posted April 19, 2006 *Experts* Posted April 19, 2006 If you wanted to bind to the DefaultView, then cast the DataSource back to a DataView instead of DataTable. You would do that if you wanted to bind to a filtered or sorted list of records - things the DataView lets you do. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
hamid Posted April 19, 2006 Author Posted April 19, 2006 thanks Nerseus, so if i want use DataView in my datagrid then how can i get DataTable from it? Quote [ once4ever ]
hamid Posted April 19, 2006 Author Posted April 19, 2006 Change sort to specific column how can i change sort to specific column in datagrid, in fact i want sort column that user change focus to it. maybe you can help me about it here before i create new topic ;) Quote [ once4ever ]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.