User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,544 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 33230 | Replies: 1
Reply
Join Date: May 2006
Posts: 13
Reputation: Swapnil Palande is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Swapnil Palande Swapnil Palande is offline Offline
Newbie Poster

How to add rows from dataset to datagridview

  #1  
Aug 23rd, 2006
Hi all,

Please solve my Problem:

I have DataGridView and Dataset. I want to add data from dataset to datagridview row by row and not by using DataGridView.DataSource method.

For ex. following is the way to do the same using Vb.net

dgClient.Columns.Add("client", "Client")
dgClient.Columns("client").Width = 150
dgClient.Columns.Add("comments", "Comments")
dgClient.Columns("comments").Width = 250

Dim i As Integer
For i = 0 To dsClient.Tables("TableClient").Rows.Count - 1
dgClient.Rows.Add()
dgClient.Rows(i).Cells("client").Value = dsClient.Tables("TableClient").Rows(i).Item("Client")
dgClient.Rows(i).Cells("comments").Value = dsClient.Tables("TableClient").Rows(i).Item("Comments")
Next

How I can do above using C#

Thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Posts: 1
Reputation: edreflak is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
edreflak edreflak is offline Offline
Newbie Poster

Re: How to add rows from dataset to datagridview

  #2  
Oct 10th, 2006
Originally Posted by Swapnil Palande View Post
Hi all,

Please solve my Problem:

I have DataGridView and Dataset. I want to add data from dataset to datagridview row by row and not by using DataGridView.DataSource method.

For ex. following is the way to do the same using Vb.net

dgClient.Columns.Add("client", "Client")
dgClient.Columns("client").Width = 150
dgClient.Columns.Add("comments", "Comments")
dgClient.Columns("comments").Width = 250

Dim i As Integer
For i = 0 To dsClient.Tables("TableClient").Rows.Count - 1
dgClient.Rows.Add()
dgClient.Rows(i).Cells("client").Value = dsClient.Tables("TableClient").Rows(i).Item("Client")
dgClient.Rows(i).Cells("comments").Value = dsClient.Tables("TableClient").Rows(i).Item("Comments")
Next

How I can do above using C#

Thanks in advance
Hi Swap, you will have to do some databinding and invoke the CurrencyManager as well. There is also a BindingManagerBase class that should prove to be usefull as well.
See www.akadia.com/services/dotnet_databinding.html

See ya
edreflak
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C# Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 9:11 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC