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 do i pass the SelectedValue/Index of a DropDownList in a GridViews EditItem Template to a Control Parameter?

How do i pass the SelectedValue/Index of a DropDownList in a GridViews EditItem Template to a Control Parameter?

Scheduled Pinned Locked Moved ASP.NET
questiondatabasewpfwcfhelp
4 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.
  • R Offline
    R Offline
    Red_Wizard_Shot_The_Food
    wrote on last edited by
    #1

    I want a column in my datagrid to be edited by a drop down list. I've put the dropdown list in the edititem template. The contents of the DropDown is sourced from an SQLDataSource And the data bindings set up a two way binding to the "Record" field. I have added this update control parameter Where: "Recorded" is the Parameter name. "gvOutgoing" is the GridView "Selected Value" is the feild i want from the dropdownlist <UpdateParameters> <asp:ControlParameter name="Recorded" controlid="gvOutgoing" propertyname="SelectedValue"/> <UpdateParameters> This generates no errors except it passes a NULL value to @Recorded :( Now I originaly thought i should put "ddlRecorded" (the drop down list) in the "controlid" as thats what i want the actaul value of. except it kept giving me this error: Could not find control "ddlRecorded" in ControlParamert "Recorded". Any adivce? Cheers

    M 1 Reply Last reply
    0
    • R Red_Wizard_Shot_The_Food

      I want a column in my datagrid to be edited by a drop down list. I've put the dropdown list in the edititem template. The contents of the DropDown is sourced from an SQLDataSource And the data bindings set up a two way binding to the "Record" field. I have added this update control parameter Where: "Recorded" is the Parameter name. "gvOutgoing" is the GridView "Selected Value" is the feild i want from the dropdownlist <UpdateParameters> <asp:ControlParameter name="Recorded" controlid="gvOutgoing" propertyname="SelectedValue"/> <UpdateParameters> This generates no errors except it passes a NULL value to @Recorded :( Now I originaly thought i should put "ddlRecorded" (the drop down list) in the "controlid" as thats what i want the actaul value of. except it kept giving me this error: Could not find control "ddlRecorded" in ControlParamert "Recorded". Any adivce? Cheers

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Because you want to get the value from the dropdownlist then the ControlID should point to this control, not the GridView. However, the dropdownlist is contained inside the GridView, therefore the value of the ControlID will be the uniqueID of the dropdownlist including the id of the containers. So it should be something like gvOutgoing$ctl02$ddlRecorded (or you can replace the $ with the :). There's one more important thing is that the uniqueId of the dropdownlist varies from row to row, so you'll have to update the ControlID dynamically according to which row is being edited.

      R 1 Reply Last reply
      0
      • M minhpc_bk

        Because you want to get the value from the dropdownlist then the ControlID should point to this control, not the GridView. However, the dropdownlist is contained inside the GridView, therefore the value of the ControlID will be the uniqueID of the dropdownlist including the id of the containers. So it should be something like gvOutgoing$ctl02$ddlRecorded (or you can replace the $ with the :). There's one more important thing is that the uniqueId of the dropdownlist varies from row to row, so you'll have to update the ControlID dynamically according to which row is being edited.

        R Offline
        R Offline
        Red_Wizard_Shot_The_Food
        wrote on last edited by
        #3

        THANK YOU SO MUCH! I've been pulling my hair out all day over that :D Could you point me to some reference about this so I could understand why it works and possibly find a way to generate that automaticly? Thanks again :)

        M 1 Reply Last reply
        0
        • R Red_Wizard_Shot_The_Food

          THANK YOU SO MUCH! I've been pulling my hair out all day over that :D Could you point me to some reference about this so I could understand why it works and possibly find a way to generate that automaticly? Thanks again :)

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Web Forms Control Identification[^] Using Parameters with Data Source Controls[^] http://www.nikhilk.net/DataSourceControlParameters.aspx[^] http://aspnet.4guysfromrolla.com/articles/110106-1.aspx[^]

          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