473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Replacing the dataSource in DataGrid

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
Nov 16 '05 #1
2 2126
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.
--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
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

"Gidi" <sh*****@hotmail.com.dontspam> wrote in message
news:F0**********************************@microsof t.com...
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

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: DraguVaso | last post by:
Hi, I need a function that gives me the number of Columns shown in a DataGrid. So I don't need to know the number of columns shown in tha DataSource, because this number can be completely...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
1
by: Richard K Bethell | last post by:
I have a page that does some complex calculations in order to serve up a datatable that is then bound to a datagrid. I want to add sort to this datagrid. Now I know that to prevent a recalc, I...
4
by: dyw55a | last post by:
Donna Mar 15, 10:11 am show options Newsgroups: microsoft.public.dotnet.framework.adonet From: "Donna" <dyw...@yahoo.com> - Find messages by this author Date: 15 Mar 2005 10:11:56 -0800...
6
by: vips | last post by:
Page_Load datagrid1.datasource=dataset1 //I am filling the datagrid and it works fine when page is displayed end ---------------
2
by: AA | last post by:
Do anyone know how to refresh the datagrid without setting datasource to nothing and initialize the grid again? My case is that I have form consisting from two part. The upper part is a datagrid...
3
by: astro | last post by:
I have a datagrid that is two levels down from the dataview (i.e. grandchild). I have spent 3 hours trying to get the syntax of determining it's real datasource (i.e. not it's source based on it's...
3
by: Richard Ryerson | last post by:
I have a general DataGridComboBoxColumn that I built using the Example in the .NET 2003 Combined Collection help file (that was a data time picker). I am able to assign a data source and display...
2
by: Brahm | last post by:
Guys, could one help em with an example with datasource and datagrid ? I want to fill a datagrid using datasource by code. BRAHM
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.