DropDownList DataBind Problem

S

Santosh

Hii I am binding data to dropdownlist but when i am binding data to it
i want to add one records programatically at the top the dropdownlist .
here i am writting code like


BindDropdownlist()
{

dataview dv = new Dataview();
dv = objSectionMAster.GetAllRecords();
Dropdownlist1.DatatTextField=dv[0]["SectionName"].Tostring();
Dropdownlist1.DatatValueField=dv[0]["SectionID"].ToString();
Dropdownlist1.DataSource = dv;
Dropdownlist1.DataBind();

}
 
E

Eliyahu Goldin

It probably should look like

BindDropdownlist()
{

dataview dv = new Dataview();
dv = objSectionMAster.GetAllRecords();
Dropdownlist1.DataTextField="SectionName";
Dropdownlist1.DataValueField="SectionID";
Dropdownlist1.DataSource = dv;
Dropdownlist1.DataBind();
Dropdownlist1.Items.Insert(0, new ListItem("new text", "new value"));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top