|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Insert item into dropdownI am trying to insert an item into a dropdown which is bound to an
sqldatasource. Nothing happens when I place the following code in page load and render event. Is the datasource overriding my insert or am I doing something wrong Dim lstitemcompany As New ListItem lstitemcompany.Text = "Select a company" lstitemcompany.Value = "" drpCompanies.Items.Insert(0, lstitemcompany) do the insert in the DataBound event handler:
protected void DropDownList1_DataBound(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; ddl.Items.Insert(0, new ListItem("text", "value")); } Chris wrote: Show quoteHide quote > I am trying to insert an item into a dropdown which is bound to an > sqldatasource. Nothing happens when I place the following code in page load > and render event. Is the datasource overriding my insert or am I doing > something wrong > > Dim lstitemcompany As New ListItem > > lstitemcompany.Text = "Select a company" > > lstitemcompany.Value = "" > > drpCompanies.Items.Insert(0, lstitemcompany)
Fundamental ASP.NET question
How can I set an app to autorun? Using CSS with Grids/Tables Data Binding and formatting Change Property on Master Page at runtime? OpenPageInsidePage One Root Web Site - Many Businesses Using Same ASP.NET Code Hide empty image placeholder in repeater control. whats happenig inside the global.asax Forcing An Authorize in Forms Authentication |
|||||||||||||||||||||||