Users Pricing

forum

Home Forums Populating drop down list from the database – MindStick

Populating drop down list from the database

Anonymous User 2103 17 Nov 2014

I used this c# code to add items in dropdownlist(ddlSub) from the table sub_info. But what I want is to add the value of the items in dropdownlist(ddlSub) from the same table which also has a column named sub_id of datatype varchar(50). 

private void bind_ddlSub()
{
 
    ddlSub.Items.Insert(0, "-Choose-");
    datatable_object = methodClassFunc.getData("select sub_name from sub_info");
    for (int i = 0; i <= datatable_object.Rows.Count - 1; i++)
    {
        ddlSub.Items.Add(Convert.ToString(datatable_object.Rows[i]["sub_name"]));
    }
}


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md