473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagridview control in .net

38 New Member
Hi..
Can anyone plzzz suggest me how to bind data to Datagridview control from database (Sql server 2000) in c#.net(windows Application).I have one single record in my table,this single record must be displayed in the grid in single column.Plzz provide the code..

Thanks in advance
siri
Feb 19 '08 #1
3 873
dip_developer
648 Recognized Expert Contributor
Hi..
Can anyone plzzz suggest me how to bind data to Datagridview control from database (Sql server 2000) in c#.net(windows Application).I have one single record in my table,this single record must be displayed in the grid in single column.Plzz provide the code..

Thanks in advance
siri
populate a datatable or dataset...set the datasource of that gridview to the table or dataset.....
Expand|Select|Wrap|Line Numbers
  1.  GridView1.DataSource = dt; 
  2. GridView1.DataBind();
  3.  
  4.  
or,
Expand|Select|Wrap|Line Numbers
  1.  GridView1.DataSource = DataSet1.Tables(dt); 
  2. GridView1.DataBind();
  3.  
  4.  
Feb 19 '08 #2
siri11
38 New Member
populate a datatable or dataset...set the datasource of that gridview to the table or dataset.....
Expand|Select|Wrap|Line Numbers
  1.  GridView1.DataSource = dt; 
  2. GridView1.DataBind();
  3.  
  4.  
or,
Expand|Select|Wrap|Line Numbers
  1.  GridView1.DataSource = DataSet1.Tables(dt); 
  2. GridView1.DataBind();
  3.  
  4.  
Thank u so much...
But....
I already tried using this.but it doesn't work "DataGridView" control for Windows App doesn't have the "DataBind" method.And I also think that GridView control cannot be used for Windows appln,it is for web applns.
Feb 19 '08 #3
Plater
7,872 Recognized Expert Expert
For DataGridView's, all you need to do is set the datasource and it will populate for you.
Feb 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: DraguVaso | last post by:
Hi, I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List of a custom class0: lstMyPersonnes = New List(Of clsPersonne). When I add a new clsPersonne to lstMyPersonnes,...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
1
by: Rich | last post by:
Hello, I am reading data from a sql server table that is under replication. This table has the replicatin GUID column that is generated with replicatin. I am reading the data from a...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
0
by: RickH | last post by:
Has anyone tried wrapping the DataGridView control itself as a custom Cell/Column control. So that I can have a child DataGridView appear in a column of a parent DataGridView so that the...
1
by: Karl | last post by:
Hi all... This is a good one. You'll like this... I am working on a course management tool that allows certain Courses to be cross referenced with Job Roles and, when they are, whether the...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
1
by: Jeff | last post by:
Hey ..NET 2.0 I've created a User Control which contain a DataGridView. This User Control is displayed on a TabPage. This TabPage is added to the TabControl during runtime. The problem is...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
4
by: alex21 | last post by:
Ok im getting this exception from a DataGridView control in my program. System.ArgumentOutOfRangeException was unhandled Message="Value of '132' is not valid for 'Value'. 'Value' should be...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.