Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

Bind DataGridView Combobox cell with DataSource

 by Ankur Gupta on Jun 04, 2010

How can we bind DataGridView Combobox cell with DataSource
Comments: 0 Views: 6400 Printable Version 
Here is the code to Bind DataGridView combobox cell with DataSource
First insert all items in a List of Strings and then Bind this string with DataGridView combobox cell
'grdBilling is a DataGridView

Dim
List As New List(Of String)

strsql =
"Select BatchNo from Purchase where Code = '" & grdBilling.Rows(e.RowIndex).Cells(0).Value & "'"
Dim objDataAdapter As New SqlClient.SqlDataAdapter(strsql, Conn)
objDataAdapter.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
For item As Integer = 0 To ds.Tables(0).Rows.Count - 1
myList.Add(ds.Tables(0).Rows(item)(0).ToString())
Next
Else
End If
If ds.Tables(0).Rows.Count > 0 Then
'Cast DataGridView cell with DataGridView combobox cell  and strDataSource
 

CType
(grdBilling.Rows(e.RowIndex).Cells(2), DataGridViewComboBoxCell).DataSource = myList
End If
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
Nevron Gauge for SharePoint
Become a Sponsor

 Blogger's Profile
Age: 29
Location:
Title: Project Manager
Joined: May 15, 2010
Education: Masters Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.