Replacing the dataSource in DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

i have a dataGrid and few radio buttons.
i want that each time the radio buttons change the dataGrid dataSource and
dataMember will change to.

i know how to change the dataMember but when i tried to make the dataSource
property to be the new dataSource (for example: if it was
dataGrid1.DataSource="a" when i pressed the radioButton i changed it to be
dataGrid1.DataSource="b") but what i'm getting is an empty table with a "+"
on it that when i press it i get my new table.
how can i get my new table without this + ?

thanks
 
Hi Gidi,

What kind of datasource are you using? In my test grid using two separate datatables with different number of lines and columns I could swap between them using radiobuttons just fine.

Note that the documentation states you should use SetDataBinding() at run time.

The DataSource should be a DataTable, DataView, DataSet or DataViewManager. Any other objects must implement IListSource or IList.
 
If using DataSource and DataMember, then I assume you're using a DataSet.
The appearance you described tends to be what you get when the grid doesn't
know which table to look at. Check the thread above titled something like
"Very Basic Datagrid Help Needed" for a simple solution.

I'm not sure if you're using web forms or regular or if that makes a
difference? But what I'm doing with Windows Forms is using Columns Styles.
You can set these up in code and tell the grid in code which you want to
use -- this way you have control over the appearance of the grid. That's a
more advanced topic, and any decent C# book should have a section that tells
you how to use Column Styles.

-Rachel
______________________________________________________________
Roydan Enterprises Ltd
602 North 9th Street
Manitowoc, WI
54220-3924
 
Back
Top