Not Getting Data in DropDownList

Results 1 to 2 of 2

Thread: Not Getting Data in DropDownList

  1. #1
    Join Date
    Dec 1969

    Default Not Getting Data in DropDownList

    I am new to ASP.NET. <BR>I have declared Connection, Adapter and Data Set info in Global.asax file in Session_Start. I wanted to attach DataSource with an DropDownList Server Control. But no Data Source is available for me in DropDownList Properties window, I filled the <BR>Dataset and bind the DropDownList control in Code-Behind file, but nothing happened, i am seeing the blank DropDownList. What could be the error.

  2. #2
    Join Date
    Dec 1969

    Default Maybe this sample code...

    will help you out. Post back if you need more explanation.<BR><BR>Sub Page_Load(Sender As Object, E As EventArgs)<BR><BR> If Not Page.IsPostBack Then<BR> DropDownList1.DataTextField = "OrderID"<BR> DropDownList1.DataSource = GetOrders()<BR> DropDownList1.DataBind()<BR> End If<BR><BR>End Sub<BR><BR> Function GetOrders() As System.Data.DataSet<BR> Dim connectionString As String = "connection info here"<BR> Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)<BR><BR> Dim queryString As String = "query here"<BR> Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand<BR> dbCommand.CommandText = queryString<BR> dbCommand.Connection = dbConnection<BR><BR> Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter<BR> dataAdapter.SelectCommand = dbCommand<BR> Dim dataSet As System.Data.DataSet = New System.Data.DataSet<BR> dataAdapter.Fill(dataSet)<BR><BR> Return dataSet<BR> End Function<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts