View Single Post
  #5 (permalink)  
Old May 25th, 2007, 07:36 AM
dparsons dparsons is offline
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First, when talking about web design, the Z-Index is a positing element used in CSS and has nothing to do with the values in your dropdown.

Secondly, the reason you got an error when you tried to place an item at index 1 is because if you don't have a value at index 0 hence index 1 can't exist.

Lastly, call your Insert AFTER you have databound the control to its datasource. This code below works as it is expected (C#)

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.drp.Items.Insert(0, "");
            this.drp.Items.Insert(1, "foo");
        }
    }

My ddl, when rendered, has a blank entry and then the element foo.

hth

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Reply With Quote