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. select item in dropdownlist & display in datalist

select item in dropdownlist & display in datalist

Scheduled Pinned Locked Moved ASP.NET
questionhelp
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.
  • C Offline
    C Offline
    Chrissy Callen
    wrote on last edited by
    #1

    Hi there...im writing a program where basically a user should select his/her name from a dropdownlist and then all details pertaining to that particular user are displayed in the datalist. At the moment the datalist is displays records for all users. How do i bind the records in the datalist to the selected item in the dropdownlist? Any help much appreciated - Thanks :) Chrissy Callen

    M 1 Reply Last reply
    0
    • C Chrissy Callen

      Hi there...im writing a program where basically a user should select his/her name from a dropdownlist and then all details pertaining to that particular user are displayed in the datalist. At the moment the datalist is displays records for all users. How do i bind the records in the datalist to the selected item in the dropdownlist? Any help much appreciated - Thanks :) Chrissy Callen

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi there. You could create an event handler for the OnSelectedIndexChanged that re-binds the grid using the SelectedValue of the dropdownlist. Also - make sure the dropdownlist has its AutoPostBack property set to true. Something like this maybe:

      <asp:DropDownList id="myDD" runat="server"
      AutoPostBack="true"
      OnSelectedIndexChanged="myDD_SelectedIndexChanged">
      ... items ...
      </asp:DropDownList>

      <asp:DataGrid id="myGrid" runat="server">
      ... stuff ...
      </asp:DataGrid>

      <script runat="server">
      private void myDD_SelectedValueChanged(object sender,
      EventArgs e)
      {
      // get the drop down selected value
      string sValue = myDD.SelectedValue;

      // now re-execute whatever code was
      // binding the grid, applying sValue
      // as criteria
      BindMyGrid(sValue);
      

      }

      private BindMyGrid(string sValue)
      {
      // if the passed in value is null, bind all data
      if (sValue == null)
      // ... bind all data
      else
      // ... only bind the one record based on sValue
      }

      </script>

      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