forum

Home / DeveloperSection / Forums / Populating drop down list from the database

Populating drop down list from the database

Anonymous User 1704 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"]));
    }
}


Updated on 17-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By