Public Function ToDataSetbyOle(pathName As String, SheetName As String) As DataSet
Dim strQuery As String = "SELECT * FROM [" & SheetName & "]"
Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " & pathName & "; Extended Properties = ""Excel;HDR=YES;FMT=""")
conn.Open()
Dim adapter As New System.Data.OleDb.OleDbDataAdapter(strQuery, conn)
Dim ds As New System.Data.DataSet("Excel File")
adapter.Fill(ds)
conn.Close()
Return ds
End Function
DropDownlist1.DataSource = dataSet.Tables("Table1")
Dropdownlist1.DataTextField = "username"
Dropdownlist1.DataValueField = "userid"
DropDownlist1.DataBind()
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
venkatmca008
Participant
1810 Points
341 Posts
Re: How to bind dropdown values in excel
Feb 21, 2012 03:52 PM|LINK
try try this..
Dim strQuery As String = "SELECT * FROM [" & SheetName & "]" Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " & pathName & "; Extended Properties = ""Excel;HDR=YES;FMT=""") conn.Open() Dim adapter As New System.Data.OleDb.OleDbDataAdapter(strQuery, conn) Dim ds As New System.Data.DataSet("Excel File") adapter.Fill(ds) conn.Close() Return ds End Function DropDownlist1.DataSource = dataSet.Tables("Table1") Dropdownlist1.DataTextField = "username" Dropdownlist1.DataValueField = "userid" DropDownlist1.DataBind()Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com