473,816 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.DataS ource="a" when i pressed the radioButton i changed it to be
dataGrid1.DataS ource="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 2153
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*****@hotmai l.com.dontspam> wrote in message
news:F0******** *************** ***********@mic rosoft.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.DataS ource="a" when i pressed the radioButton i changed it to be
dataGrid1.DataS ource="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
4628
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 something else than the number of columns defined in the currently active TableStyle! I currently use DataGrid.TableStyles(0).GridColumnStyles.Count, but i know this won't work when using more than one TableStyle, or having a TableStyle with another...
0
1776
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 happened always whenever DataSource is set, only called sometimes, in a series of setting DataSource, I could get this setting focus only one time . Can anybody help me how to stop this one. system.windows.forms.dll!
1
1089
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 could throw the DataTable in the viewstate and rebind at every hit. However, I am wondering if I have this available as an option - can I assign a DataTable the value of the ..DataSource property of the datagrid? It would lighten the burden on...
4
6202
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 Local: Tues, Mar 15 2005 10:11 am Subject: VB.NET dynamically create datagrid and set its datasource Reply | Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse
6
1971
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
2676
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 while the lower is the record detail. Once user, said selected/hightlighted row 3 for editing the detail info. Then, user click "Save". I want the datagrid to be refreshed so as to displaying the latest changes of the record info without moving...
3
1623
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 relationship with the dataview). argh! company ---> person --->contact
3
1406
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 / value members so the ComboBox is data bound and that works, to a point. What generally works is the ComboBox get's populated and the ComboBox shows itself when the appropriate column/row is selected. When the ComboBoxColumn isn't selected it...
2
994
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
9738
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10674
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10149
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9227
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4361
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3033
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.