filling a dropdownlist?
how to fill a dropdownlist?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
David JohnsonPosted Jun 26, 2008, 11:23 PM
control = (DropDownList)controlRow.FindControl(ControlName);
foreach(object choice in SomeChoiceCollectionObject)
{
ListItem item = new ListItem(choice.Name, choice.ID.ToString());
control.Items.Add(item);
}
Raj KumarPosted Dec 18, 2007, 11:19 PM
Private Sub FillDropDownList()
Dim ObjDataSet as DataSet = Helper.FillDropDownList()
If Not Object.Equals(ObjDataSet, Nothing) Then
If ObjDataSet.Tables(0).Rows.Count > 0 Then
DropDownList.DataValueField = "Name"
DropDownList.DataTextField = "Name"
DropDownList.DataSource = ObjDataSet.Tables(0)
DropDownList.DataBind()
End If
End Sub
Here Name is column name which you want to fill in dropdown list. i hope this will help you.
swarnaPosted Dec 6, 2007, 10:37 AM
brian doboshPosted Dec 6, 2007, 10:33 AM
example:
comboBox1.Items.Add("Item 1");
comboBox1.Items.Add("Item 2");