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. Displaying a passed value from a previous page in a databound DDL

Displaying a passed value from a previous page in a databound DDL

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorialannouncementworkspace
3 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.
  • B Offline
    B Offline
    beacon dartmouth
    wrote on last edited by
    #1

    I need to display a value passed through a session variable to a DropDownList that is already bound to a DB table and do the same to a dependent child DDL. I hope I'm explaining this clearly. In essence I have two DDLs bound to two separate data tables. The value selected on the first DDL will 'filter' out and display only related values in the second DDL. This much is working fine. Now, what I need is to have the first DDL display a value passed through a session variable from a previous page on both DDLs so that the user begins an update session with valid current information. It shouldn't be so hard to accomplish but I haven't had much luck on this one, yet. I have read a few threads on this forum but it isn't clear to me how to apply the statement: .SelectedIndex = .Items.IndexOf(.Items.FindByValue(etc etc etc ) I'm not even working in a backcode environment as all my pages are inline coded. Any help on this subject would be deeply appreciated. a-c

    A 1 Reply Last reply
    0
    • B beacon dartmouth

      I need to display a value passed through a session variable to a DropDownList that is already bound to a DB table and do the same to a dependent child DDL. I hope I'm explaining this clearly. In essence I have two DDLs bound to two separate data tables. The value selected on the first DDL will 'filter' out and display only related values in the second DDL. This much is working fine. Now, what I need is to have the first DDL display a value passed through a session variable from a previous page on both DDLs so that the user begins an update session with valid current information. It shouldn't be so hard to accomplish but I haven't had much luck on this one, yet. I have read a few threads on this forum but it isn't clear to me how to apply the statement: .SelectedIndex = .Items.IndexOf(.Items.FindByValue(etc etc etc ) I'm not even working in a backcode environment as all my pages are inline coded. Any help on this subject would be deeply appreciated. a-c

      A Offline
      A Offline
      Albert Pascual
      wrote on last edited by
      #2

      What about DDL.SelectedValue = "Your value"?

      B 1 Reply Last reply
      0
      • A Albert Pascual

        What about DDL.SelectedValue = "Your value"?

        B Offline
        B Offline
        beacon dartmouth
        wrote on last edited by
        #3

        Thanks for replying. The "Your value" is a string and what the SelectedValue attribute needs is an index (0,1,2,3) for the assignment to work, which I'm almost positive there's a way of getting without looping over a dataset and finding it that way. As of the past few days I've been reading about the FindByValue and IndexOf in uses such as: ddlDivName.Items.FindByValue (drDiv.getValue().ToString()).Selected = True but I'm not sure where to plug in the string value in my session variable. As it is the compiler returns: System.InvalidOperationException: Invalid attempt to read when no data is present. at System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i) at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) at ASP.appDetailEdit_aspx.Page_Load It shouldn't have to be so hard, right?

        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