Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

Help. Getting exception when I rebind grid to another dataset and change column names

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AboutJAV@gmail.com - 11 Jan 2007 18:40 GMT
Hi,

I am using a datagrid and two dataset with different data. Both views
of the grid contains 5 columns. I toggle between two different views of
the grid which display different types of data. When I toggle, I change
the last 3 columns to different name and bind a different dataset. When
I startup the application, the first dataset when I click on any empty
cells, it works find. However, when I switch for the first time to the
alternative dataset and change the name, it will throw an exception

Index was out of range. Must be non-negative and less than th esize of
the collection.
Parameter name: index

When I keep the column names the same between the two grid views, it
works fine. However, I need to change the column names to indentify the
column type of data.

Any help is appreciated.
RobinS - 12 Jan 2007 06:36 GMT
1) Are you using the 2003 or 2005 version of VB/C#?
2) Windows Forms or Webforms?

Robin S.
-----------------
> Hi,
>
[quoted text clipped - 19 lines]
>
> Any help is appreciated.
RobinS - 12 Jan 2007 06:39 GMT
Okay, it's late, I didn't realize this was posted in the
windowsforms ng. Phew.

If you're using the 2005 version, you can put a binding source
between your data source (dataset) and your grid (datagridview).

Dim nwData as CustomersDataSet = CustomersDataSet.GetCustomers()
m_CustomersGrid.DataSource = m_CustomersBindingSource
m_CustomersBindingSource.DataSource = nwData.Customers

When you want to change your data source, change the datasource
that is bound to the Binding Source, and the grid will
change automatically. THe binding source is like the glue
between the data source and the grid.

That's my theory, anyway.

Robin S.
-------------------------------------
> 1) Are you using the 2003 or 2005 version of VB/C#?
> 2) Windows Forms or Webforms?
[quoted text clipped - 27 lines]
>>
>> Any help is appreciated.
AboutJAV@gmail.com - 12 Jan 2007 16:26 GMT
Thanks RobinS,

I forgot to add

Grid.DataBind(DataSet);

after the associating DataSource.

Thanks.

> Okay, it's late, I didn't realize this was posted in the
> windowsforms ng. Phew.
[quoted text clipped - 46 lines]
> >>
> >> Any help is appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.