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. is there some way i can give the RowIndex as the data key in a gridview

is there some way i can give the RowIndex as the data key in a gridview

Scheduled Pinned Locked Moved ASP.NET
question
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.
  • F Offline
    F Offline
    Flavia A
    wrote on last edited by
    #1

    is there some way i can give the RowIndex as the data key in a gridview?

    S 1 Reply Last reply
    0
    • F Flavia A

      is there some way i can give the RowIndex as the data key in a gridview?

      S Offline
      S Offline
      sashidhar
      wrote on last edited by
      #2

      What r u trying to do can you be more clear..!

      LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

      F 1 Reply Last reply
      0
      • S sashidhar

        What r u trying to do can you be more clear..!

        LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

        F Offline
        F Offline
        Flavia A
        wrote on last edited by
        #3

        i actually want to use to link buttons in one gridview .both the buttons perform different actions on click. earlier i had done this by using the protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) event for one button and for the other button i used protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Session["sr_no"] = Convert.ToString(GridView1.DataKeys[e.RowIndex].Value); } here i had set a serial no from the data base as the data key and it worked fine but my current table does not have any serial no or a counter so am not able to set the datakey.

        S 1 Reply Last reply
        0
        • F Flavia A

          i actually want to use to link buttons in one gridview .both the buttons perform different actions on click. earlier i had done this by using the protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) event for one button and for the other button i used protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Session["sr_no"] = Convert.ToString(GridView1.DataKeys[e.RowIndex].Value); } here i had set a serial no from the data base as the data key and it worked fine but my current table does not have any serial no or a counter so am not able to set the datakey.

          S Offline
          S Offline
          sashidhar
          wrote on last edited by
          #4

          I think You are going in the wrong way ..! first try to use command button and handle the events in ItemCommand AND handle the command name by e.CommandName

          LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

          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