Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to retrieve values in a textbox according to the selected value in the dropdownlist in Web application

how to retrieve values in a textbox according to the selected value in the dropdownlist in Web application

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorialquestion
7 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jadhavShubhangi
    wrote on last edited by
    #1

    hello......... I am new in asp.net.I have given dropdownlist and bind data to this one.If I am selecting the value in dropdownlist according their values display into textbox how to do this? I have written the code is private void LoadDropdown() { tblItemDetails1TableAdapter l_tblItemDetails1TableAdapter = new tblItemDetails1TableAdapter(); DataTable l_tblItemTable = l_tblItemDetails1TableAdapter.GetData(); dropItemName.DataTextField = "ItemName"; dropItemName.DataValueField = "ItemId"; dropItemName.DataSource = l_tblItemTable; } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadCombo(); } } Pls help me.......... Thanks.

    A T S P 4 Replies Last reply
    0
    • J jadhavShubhangi

      hello......... I am new in asp.net.I have given dropdownlist and bind data to this one.If I am selecting the value in dropdownlist according their values display into textbox how to do this? I have written the code is private void LoadDropdown() { tblItemDetails1TableAdapter l_tblItemDetails1TableAdapter = new tblItemDetails1TableAdapter(); DataTable l_tblItemTable = l_tblItemDetails1TableAdapter.GetData(); dropItemName.DataTextField = "ItemName"; dropItemName.DataValueField = "ItemId"; dropItemName.DataSource = l_tblItemTable; } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadCombo(); } } Pls help me.......... Thanks.

      A Offline
      A Offline
      Arun Jacob
      wrote on last edited by
      #2

      From javascript or code-behind? If you are looking for code behind, then use SelectedIndex_Changed event of dropdown and use, ddl.SelectedItem.Text

      Arun Jacob http://codepronet.blogspot.com/

      1 Reply Last reply
      0
      • J jadhavShubhangi

        hello......... I am new in asp.net.I have given dropdownlist and bind data to this one.If I am selecting the value in dropdownlist according their values display into textbox how to do this? I have written the code is private void LoadDropdown() { tblItemDetails1TableAdapter l_tblItemDetails1TableAdapter = new tblItemDetails1TableAdapter(); DataTable l_tblItemTable = l_tblItemDetails1TableAdapter.GetData(); dropItemName.DataTextField = "ItemName"; dropItemName.DataValueField = "ItemId"; dropItemName.DataSource = l_tblItemTable; } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadCombo(); } } Pls help me.......... Thanks.

        T Offline
        T Offline
        test 09
        wrote on last edited by
        #3

        //dropItemName_SelectedIndexchanged event
        TextBox1.Text=dropItemName.SelectedItem.Text;

        J M 2 Replies Last reply
        0
        • T test 09

          //dropItemName_SelectedIndexchanged event
          TextBox1.Text=dropItemName.SelectedItem.Text;

          J Offline
          J Offline
          jadhavShubhangi
          wrote on last edited by
          #4

          thanks for reply..

          1 Reply Last reply
          0
          • T test 09

            //dropItemName_SelectedIndexchanged event
            TextBox1.Text=dropItemName.SelectedItem.Text;

            M Offline
            M Offline
            Morgs Morgan
            wrote on last edited by
            #5

            Also make sure that your dropItemName AutoPostBack property is set to true

            1 Reply Last reply
            0
            • J jadhavShubhangi

              hello......... I am new in asp.net.I have given dropdownlist and bind data to this one.If I am selecting the value in dropdownlist according their values display into textbox how to do this? I have written the code is private void LoadDropdown() { tblItemDetails1TableAdapter l_tblItemDetails1TableAdapter = new tblItemDetails1TableAdapter(); DataTable l_tblItemTable = l_tblItemDetails1TableAdapter.GetData(); dropItemName.DataTextField = "ItemName"; dropItemName.DataValueField = "ItemId"; dropItemName.DataSource = l_tblItemTable; } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadCombo(); } } Pls help me.......... Thanks.

              S Offline
              S Offline
              Sandeep Mewara
              wrote on last edited by
              #6

              For server side, as suggested use SelectedIndexChanged event.. For client side, add the onchange attribute to the dropdown where in the javascript use this onchange to set the textbox value (assign the value that is selected in dropdown)

              1 Reply Last reply
              0
              • J jadhavShubhangi

                hello......... I am new in asp.net.I have given dropdownlist and bind data to this one.If I am selecting the value in dropdownlist according their values display into textbox how to do this? I have written the code is private void LoadDropdown() { tblItemDetails1TableAdapter l_tblItemDetails1TableAdapter = new tblItemDetails1TableAdapter(); DataTable l_tblItemTable = l_tblItemDetails1TableAdapter.GetData(); dropItemName.DataTextField = "ItemName"; dropItemName.DataValueField = "ItemId"; dropItemName.DataSource = l_tblItemTable; } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadCombo(); } } Pls help me.......... Thanks.

                P Offline
                P Offline
                Priya Prk
                wrote on last edited by
                #7

                in the selectedindexchanged event handler of the dropdown: Textbox1.Text = DropDown1.Text

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups