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

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();

thanks sir :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.