Results 1 to 5 of 5

Thread: VB.net + ASP.net dropdownlist selection the first item per default

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    514

    VB.net + ASP.net dropdownlist selection the first item per default

    Hi
    I am not sure if this is the right forum and I apologize before hand if it is not.

    My problem is the I am populating a dropdownlist from a database in a simple ASP.net webform and all good except that the initial text in the dropdownlist is the first item in the list while want it to be none of the items.
    I guess that is the normal behaviour or something but how will I make it so that none of the times are selected. I tried "if Not postback", set the selected index to -1 etc but no luck.

    I am populating it at page load and manually (not binding it)

    Thanks for any help.

    Edit:
    Just noticed another thing; there are also some other dropdownliast that get populated based on the selection of the first dropdownlist. However, they are not populated at page load even though there is an item selected in the first dropdownlist.
    Last edited by Grand; Jul 20th, 2021 at 02:59 AM.

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: VB.net + ASP.net dropdownlist selection the first item per default

    Hi Grand,

    You haven't explained why you want the first item to be blank. My guess would be that you want the user to be able to enter something in there, so...
    If I'm right, why not make the first item on your list "Enter your text here", or even just a few space characters.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    514

    Re: VB.net + ASP.net dropdownlist selection the first item per default

    Hi
    You are correct. So I want that users select one of the items and before that nothing should happen.

    Well, I was hoping to avoid that extra dummy item but if that is the way to go around it, then so be it.

    I just started ASP.net. very noob :
    thanks for the tip.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: VB.net + ASP.net dropdownlist selection the first item per default

    Quote Originally Posted by Grand View Post
    Hi
    I am not sure if this is the right forum and I apologize before hand if it is not.
    https://www.vbforums.com/forumdispla...d-ASP-NET-Core

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: VB.net + ASP.net dropdownlist selection the first item per default

    Thread moved from the 'VB.Net' forum to the 'ASP.NET And ASP.NET Core' forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width