Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a combobox in c# windows base project in which first two items will be manually inserted and after that it will show the items from database table.
for eg.

Select
Add new

product1
product 2

where select and add new is inserted manually from control where as product 1,2 will be append it from database. when click on combobox it should show all the 4 items.
in asp.net we use appent property of control for that but in c#.net I don't know pls help
Posted

1 solution

It is VB code similary you can do in C#


VB
Dim ddlCargoGrade As DropDownList = CType(lItem.FindControl("ddlItems"), DropDownList)
          ddlCargoGrade.Visible = True
          Dim emptyItem As ListItem = New ListItem("", 0)
          ddlCargoGrade.Items.Insert(0, emptyItem)
          ddlCargoGrade.AppendDataBoundItems = True
          ddlCargoGrade.DataSource = TestCache.Get_All
          ddlCargoGrade.DataTextField = "GetName"
          ddlCargoGrade.DataValueField = "GetId"
          ddlCargoGrade.SelectedIndex = 0
          ddlCargoGrade.DataBind()
          ddlCargoGrade.Visible = False
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900