Newbie question - Use dropdownlist or textbox for db insert?

Discussion in 'ASP .Net' started by benjamin.derr@css-security.com, May 29, 2007.

  1. Guest

    I have a webform that i'm using to insert a new entry into a database
    table. For some of the columns, I'd like to give the user the option
    of using a dropdownlist or a textbox, in order to allow the user to
    use an existing entry, or to create a new entry value. However, when
    the user posts/submits, the form is only using the value from textbox
    entry, and not the dropdownlist. I do have the dropdownlist bound to
    a select distinct query for that column. Not being very familiar with
    coding here, I probablyI need to put some stuff in the code behind,
    but am not sure exactly what I should be doing here. I'm using
    ASP.Net 2 with vb.
     
    , May 29, 2007
    #1
    1. Advertising

  2. Tom Guest

    get the selected item of the drop down

    string strGetValue = DropDownList.SelectedItem.Text or if you want the value
    string strGetValue = DropDownList.SelectedItem.value

    and pass strGetValue to your insert/update SQL statement




    <> wrote in message
    news:...
    >I have a webform that i'm using to insert a new entry into a database
    > table. For some of the columns, I'd like to give the user the option
    > of using a dropdownlist or a textbox, in order to allow the user to
    > use an existing entry, or to create a new entry value. However, when
    > the user posts/submits, the form is only using the value from textbox
    > entry, and not the dropdownlist. I do have the dropdownlist bound to
    > a select distinct query for that column. Not being very familiar with
    > coding here, I probablyI need to put some stuff in the code behind,
    > but am not sure exactly what I should be doing here. I'm using
    > ASP.Net 2 with vb.
    >
     
    Tom, May 29, 2007
    #2
    1. Advertising

  3. You can learn about dropdownlists here:

    http://msconline.maconstate.edu/tutorials/ASPNET20/default.htm

    See:

    6. Input and Selection Controls


    <> wrote in message news:...
    >I have a webform that i'm using to insert a new entry into a database
    > table. For some of the columns, I'd like to give the user the option
    > of using a dropdownlist or a textbox, in order to allow the user to
    > use an existing entry, or to create a new entry value. However, when
    > the user posts/submits, the form is only using the value from textbox
    > entry, and not the dropdownlist. I do have the dropdownlist bound to
    > a select distinct query for that column. Not being very familiar with
    > coding here, I probablyI need to put some stuff in the code behind,
    > but am not sure exactly what I should be doing here. I'm using
    > ASP.Net 2 with vb.
    >
     
    Jon Paal [MSMD], May 29, 2007
    #3
  4. Guest

    Ok, now I have a better idea of what is going on. I have the two
    controls in a formview template. I need to determine how to reference
    the controls inside the formview in the code behind.
     
    , May 29, 2007
    #4
  5. Jon Paal [MSMD], May 30, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    2
    Views:
    568
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  2. Natty Gur
    Replies:
    0
    Views:
    481
    Natty Gur
    Jul 22, 2003
  3. tanmaypatankar
    Replies:
    0
    Views:
    1,091
    tanmaypatankar
    Dec 18, 2007
  4. Li Pang

    Use dropdownlist as textbox

    Li Pang, Aug 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    142
    Dan Christensen
    Aug 10, 2006
  5. Rob

    Use textbox to filter a DropDownList

    Rob, Mar 20, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    383
Loading...

Share This Page