i'm developing application in .net using c# that has 1 dropdown list .I want to take data in it .to show in list.please suggest me some help

select the info that you want into a datatable,
set the datatable as the datasource for the dropdown. call the databind function. and make sure you specify in the dropdown control which columns have correspond with the DataValueField and DataTextField

can u give code for the get data from database in dropdown list

<asp:SqlDataSource ID="sda_nw1" runat="server" ConnectionString='<%$ ConnectionStrings:NORTHWIND %> ' 
        SelectCommand="SELECT orders.customerid, ContactName, count(OrderID) as numorders FROM orders join customers on orders.CustomerID=Customers.CustomerID group by orders.customerid, ContactName order by ContactName" 
        ProviderName="System.Data.SqlClient" OldValuesParameterFormatString="original_{0}">
        </asp:SqlDataSource>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="sda_nw1" DataTextField="customerid"
            DataValueField="customerid">
        </asp:DropDownList><br />

please give me the source code to retieve data from database todropdownlist in c#.net

You can add data that is returned from a reader the same way you would programmatically add items to a combobox (combobox1.Items.Add(*Object to add to combobox*);

Here is a sample of code that I did a while ago, this reads all of the Columns on a particular table and adds it to a combobox.

for (int i = 0; i < dr.FieldCount; i++)
            {
                Fields.Add(dr.GetName(i));
                comboBox1.Items.Add(dr.GetName(i));


            }

i'm developing application in .net using c# that has 1 dropdown list .I want to take data in it .to show in list.please suggest me some help

eg: Label=DropDownlist

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadFrom();
        }

    }
    public void loadFrom()
    {
        string insertstring = @"select * from ddlFFromDB";
        SqlConnection conn = new SqlConnection("Server=SSK-          PC\\MSSQL2008;database=*******;User ID=******;Password=*********;");
        conn.Open();
        SqlCommand cmd = new SqlCommand(insertstring, conn);
        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        DataSet data = new DataSet();
        adapter.Fill(data);
        conn.Close();


        ddlFrom.DataSource=data.Tables[0];
        ddlFrom.DataValueField = "FromId";
        ddlFrom.DataTextField = "From";
        ddlFrom.DataBind();

    }
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.