issue when populating data in textbox on dropdownlist box selection

Discussion in 'ASP .Net' started by Dhananjay, Dec 18, 2007.

  1. Dhananjay

    Dhananjay Guest

    Hi all,

    i have a webpage on which
    first thing i am adding record using textboxadd and buttonadd.
    ------
    this works fine
    second thing i have dropdownlist box on which i will select an item,
    based on this selection , i have another textboxforedit(this textbox
    will be populated with dropdownlist box selected item).
    in this textboxforedit i will modify the data and i have a update
    button,if i click update button, it should be updated in the table.


    please help me to solve this problem.it's urgent
    please send me some code to solve this issue.


    Thanks in advance
    Dhananjay
    Dhananjay, Dec 18, 2007
    #1
    1. Advertising

  2. Re: issue when populating data in textbox on dropdownlist boxselection

    On Dec 18, 2:05 am, Dhananjay <> wrote:
    > ...i have dropdownlist box on which i will select an item,
    > based on this selection , i have another textboxforedit(this textbox
    > will be populated with dropdownlist box selected item).
    > in this textboxforedit i will modify the data and i have a update
    > button,if i click update button, it should be updated in the table.


    This is nothing complicated, I'm assuming you are trying to use a
    DropDownList to prefill a TextBox so people don't have to type common
    things.

    What you need to do is create a DropDownList with the AutoPostBack
    attribute set to True, and then handle it's SelectedIndexChanged event
    to set the Text property to the value of the SelectedValue property of
    the DropDownList:

    <asp:DropDownList ... AutoPostBack="True">
    <asp:ListItem Selected="True">Pre-typed things</asp:ListItem>
    ...
    </asp:DropDownList>
    <asp:TextBox ... />

    Here's an outline of how you would handle the event:

    Sub DropDownList1_SelectedIndexChanged(sender as object, ...)
    Handles ...
    TextBox1.Text = CType(sender, DropDownList).SelectedValue
    End Sub

    I'm not sure what you mean by updating the database, it's unstated
    whether this is a new record or editing a record, if there is already
    existing code that this will work alongside, etc. You will have to
    explain your problem further.

    -Michael Placentra II
    Mike Placentra II, Dec 23, 2007
    #2
    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. Wim
    Replies:
    1
    Views:
    426
  2. Replies:
    0
    Views:
    409
  3. Satish
    Replies:
    8
    Views:
    9,621
    Satish
    Mar 31, 2008
  4. Dhananjay
    Replies:
    0
    Views:
    99
    Dhananjay
    Dec 18, 2007
  5. Adrian
    Replies:
    1
    Views:
    207
    Bullschmidt
    Feb 18, 2004
Loading...

Share This Page