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. GridView Template Control [modified]

GridView Template Control [modified]

Scheduled Pinned Locked Moved ASP.NET
databasegraphicsquestion
5 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.
  • I Offline
    I Offline
    Ibrahim Bello
    wrote on last edited by
    #1

    Hi all, I have a gridview with a list of names. My code allows me to select and highlight all names and save to database. However I want to be able to de-select a particular row; say I select all 100 Records but I later decide I don't want to select/save a particular record and I want to select only 99 Records. For this I've added a LinkButton Control into a Template Field of the Gridview. I want when this button is clicked to change the color (de-select) this particular row. However I am not able to get a reference to the row which I want to cancel. I know if I let the user click the autogenerated select button I can get a reference to it using (grdView.SelectedIndex) but I don't want to do this. I want to be able to click the 'cancel' button, get a reference to the corresponding row and change its background color. Anyway to do this? Thanks protected void grdViewCancelButton_Click(object sender, EventArgs e) { // Get Row you want to de-select //int SelectedIndex = ? // Change Row Background //grdView.Rows[SelectedIndex].BackColor = System.Drawing.Color.Whatever; }

    modified on Tuesday, May 12, 2009 11:32 AM

    A 1 Reply Last reply
    0
    • I Ibrahim Bello

      Hi all, I have a gridview with a list of names. My code allows me to select and highlight all names and save to database. However I want to be able to de-select a particular row; say I select all 100 Records but I later decide I don't want to select/save a particular record and I want to select only 99 Records. For this I've added a LinkButton Control into a Template Field of the Gridview. I want when this button is clicked to change the color (de-select) this particular row. However I am not able to get a reference to the row which I want to cancel. I know if I let the user click the autogenerated select button I can get a reference to it using (grdView.SelectedIndex) but I don't want to do this. I want to be able to click the 'cancel' button, get a reference to the corresponding row and change its background color. Anyway to do this? Thanks protected void grdViewCancelButton_Click(object sender, EventArgs e) { // Get Row you want to de-select //int SelectedIndex = ? // Change Row Background //grdView.Rows[SelectedIndex].BackColor = System.Drawing.Color.Whatever; }

      modified on Tuesday, May 12, 2009 11:32 AM

      A Offline
      A Offline
      AlexeiXX3
      wrote on last edited by
      #2

      What if you set the CommandName of your linkbutton to Select or Cancel?? Also, you can set the CommandArgument of the linkbutton to the index of the corresponding row (from code in the rowdatabound event), and on postbacks you can access this property from code to know the index of the row clicked

      Alexei Rodriguez

      I 1 Reply Last reply
      0
      • A AlexeiXX3

        What if you set the CommandName of your linkbutton to Select or Cancel?? Also, you can set the CommandArgument of the linkbutton to the index of the corresponding row (from code in the rowdatabound event), and on postbacks you can access this property from code to know the index of the row clicked

        Alexei Rodriguez

        I Offline
        I Offline
        Ibrahim Bello
        wrote on last edited by
        #3

        Thanks, This works :)

        A 1 Reply Last reply
        0
        • I Ibrahim Bello

          Thanks, This works :)

          A Offline
          A Offline
          AlexeiXX3
          wrote on last edited by
          #4

          Glad it worked Wich one of the 2 approaches did yo use??

          Alexei Rodriguez

          I 1 Reply Last reply
          0
          • A AlexeiXX3

            Glad it worked Wich one of the 2 approaches did yo use??

            Alexei Rodriguez

            I Offline
            I Offline
            Ibrahim Bello
            wrote on last edited by
            #5

            I'm actually using the select button for the meantime. If I will use the template linkbutton, I will go with the 2nd approach. On RowDataBound I will hook the linkbutton's CommandArgument to the Row Index and access this on the linkbutton's eventhandler. Thanks for the lead!

            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