none
How to assign a value from drop down box to text box RRS feed

  • Question

  • Hello, I'm trying a write a code where the selected value from the dropdown box can be displayed on the text box and so far I am unsuccessful. Could you please let me know the event type that should be used and the how the code should be written. Many Thanks!

    eds

    Thursday, July 19, 2018 11:28 AM

Answers

  • Hi de

    I think it can be set in the SelectedIndexChanged event.

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        TextBox1.Text = DropDownList1.SelectedValue
    End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by de silva Sunday, July 22, 2018 3:35 AM
    Friday, July 20, 2018 2:18 AM

All replies

  • Hello, I'm trying a write a code where the selected value from the dropdown box can be displayed on the text box and so far I am unsuccessful. Could you please let me know the event type that should be used and the how the code should be written. It's written in VB and this is for ASP.net application Many Thanks!

    eds



    eds

    Thursday, July 19, 2018 11:29 AM
  • Hello,

    You should ask this question in the ASP.NET forums

    https://forums.asp.net/24.aspx/1?Web+Forms+Data+Controls


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, July 19, 2018 11:59 AM
    Moderator
  • Hi de

    I think it can be set in the SelectedIndexChanged event.

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        TextBox1.Text = DropDownList1.SelectedValue
    End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by de silva Sunday, July 22, 2018 3:35 AM
    Friday, July 20, 2018 2:18 AM