Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    ASP:Dropdownlist naming?

    I've go a problem with a piece of ASP code that I'm hoping someone will be able to help with?

    I'm using an ASP:dropdownlist box to pull some info from a DB, however the page I'm using it on writes the form information back in C#, which means it won't see the drop down unless it has a name, not an ID.

    I know that its not as simple as just adding name="appID" in the drop down, because I've tried that already, and it doesn't work.

    The c# command for the other fields in the form is:
    (Request.Form["Appointment"] != null ? Convert.ToString(Request.Form["Appointment"]).Replace("\"", "\"\"") : "") +

    for writing other standard input fields back to the DB, but I don't know how to do it for ASP drop downs, can anyone help?

  2. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    First of all, you are talking about ASP.NET, not ASP. So technically you are in the wrong forum.


    ASP.NET *always* assigns a name= to form fields, including dropdownlist.

    So you could simply bring the page up in a browser, click on the VIEW menu, click on the SOURCE menu item, and then look in the HTML that ASP.NET is generating to find the name it uses.

    HOWEVER... If you are using Request.Form to get values from ASP.NET controls, you are really not using ASP.NET the way it was designed to be used.

    Look here:

    That shows how you should be capturing "onchange" for asp:dropdownlist.

    Generally speaking, if you find yourself using Request.Form a lot, you haven't really bought into the ASP.NET way of handling forms.
    Be yourself. No one else is as qualified.


Posting Permissions

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