0

the code is for binding data from a gridview

Sub BindGrid()
        Dim connection As OleDbConnection
        connection = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\Karl Gennadi\Desktop\Visual Studio 2008\WebSite3\Database\dbLupon.mdb")
        connection.Open()
        
        Dim command As OleDbCommand
        command = New OleDbCommand("Select LAST_M, UNIQUE_C from tblLupon_C", connection)
        Dim DataReader As OleDbDataReader
        DataReader = command.ExecuteReader()
        GridView1.DataSource = DataReader
        GridView1.DataBind()
        connection.Close()
    End Sub

how to bind a dropdown list using the datareader?
how can i add item(s) in the dropdown list :)
thanks

2
Contributors
2
Replies
9
Views
6 Years
Discussion Span
Last Post by kgenn
0
SqlConnection con =new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString.ToString();)       
SqlCommand cmd=new SqlCommand();
cmd.connection=con;
con.open();
cmd.commandText="SELECT id,FirstName FROM tablename";
SqlDataReader dr;
dr=cmd.ExecuteReader();
ddlname.DataSource =dr;
ddlname.DataTextField = "FirstName";
ddlname.DataValueField = "id";
ddlname.DataBind();
dr.close();
con.close();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.