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. Databinding

Databinding

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-netdatabase
2 Posts 2 Posters 0 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.
  • T Offline
    T Offline
    The ANZAC
    wrote on last edited by
    #1

    Hi, i'm kinda new to the whole asp.net side of developing. I've created a web page with a combobox and textbox. I have a Database with a table (Postcodes). First of all, how do i populate the combobox with data from this table (column: towns) and, second of all, when i change item, how do i make the textbox display the postcode (a.k.a. zip code) (column: postcode). I am using visual basic as my language in visual studio 2005 with a seperate codepage for my aspx page.

    Please check out my articles: The ANZAC's articles

    M 1 Reply Last reply
    0
    • T The ANZAC

      Hi, i'm kinda new to the whole asp.net side of developing. I've created a web page with a combobox and textbox. I have a Database with a table (Postcodes). First of all, how do i populate the combobox with data from this table (column: towns) and, second of all, when i change item, how do i make the textbox display the postcode (a.k.a. zip code) (column: postcode). I am using visual basic as my language in visual studio 2005 with a seperate codepage for my aspx page.

      Please check out my articles: The ANZAC's articles

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      The ANZAC wrote:

      First of all, how do i populate the combobox with data from this table (column: towns)

      In form_load event, `SqlConnection dbConn = new SqlConnection(connectionString); dbConn.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT town FROM table1", dbConn); DataSet ds = new DataSet(); da.Fill(ds); dbConn.Close(); DropDownList1.DataSource = ds.Tables[0]; DropDownList1.DataTextField = "town"; DropDownList1.DataValueField = "postalcode"; DropDownList1.DataBind();` > The ANZAC wrote: > > second of all, when i change item, how do i make the textbox display the postcode (a.k.a. zip code) (column: postcode). `protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { txtPostalCode.Text = DropDownList1.SelectedValue; }` That's all. Hope it helps. Thanks and Regards, Michael Sync ( Blog: [http://michaelsync.net](http://michaelsync.net)) _If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read [it](http://www.codeproject.com/info/supporter.asp#supporters) here. Thank you. :)_

      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