?
Solved

Can I set a databound drop down list to be blank on page load without changing the database?

Posted on 2008-11-13
3
Medium Priority
?
375 Views
Last Modified: 2013-12-17
Can I set a databound drop down list to be blank on page load without changing the database? If so how? Thanks
0
Comment
Question by:dwezil
3 Comments
 
LVL 2

Expert Comment

by:tomasgruener
ID: 22948122
Surpress the databinding. Somewhere you have a part in the code, where you call Control.DataBind().

If you want enabling just for postbacks, then use something like this.


if(Page.IsPostBack)
    Control.DataBind();

Open in new window

0
 

Accepted Solution

by:
dwezil earned 0 total points
ID: 22948480
AppendDataBoundItems works

<asp:DropDownList runat="server" AppendDataBoundItems="true">
    <asp:ListItem>- - SELECT SOMETHING - -</asp:ListItem>
</asp:DropDownList>
0
 
LVL 3

Expert Comment

by:Rupesh P
ID: 22948666
I assume you want to clear the control in page load. rt? If So,
DropDownList1.Items.Clear()
should do the job

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question