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. How can I created a row clickabe GridView?

How can I created a row clickabe GridView?

Scheduled Pinned Locked Moved Web Development
question
5 Posts 3 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.
  • K Offline
    K Offline
    kidus12
    wrote on last edited by
    #1

    Hi How can I created a row clickabe GridView? I appreciate your cooperation kidus

    S 1 Reply Last reply
    0
    • K kidus12

      Hi How can I created a row clickabe GridView? I appreciate your cooperation kidus

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

      In the RowDataBound event handler write:

      e.Row.Attributes.Add("onclick", script);

      where 'script' is either some javascript for client-side action or if you implement the IPostBackEventHandler, it can be a postback event reference, for server-side processing.

      K 1 Reply Last reply
      0
      • S szukuro

        In the RowDataBound event handler write:

        e.Row.Attributes.Add("onclick", script);

        where 'script' is either some javascript for client-side action or if you implement the IPostBackEventHandler, it can be a postback event reference, for server-side processing.

        K Offline
        K Offline
        kidus1
        wrote on last edited by
        #3

        hi szukuro But I am using gridview server control and C#.Pls mak it clear thanks

        S 1 Reply Last reply
        0
        • K kidus1

          hi szukuro But I am using gridview server control and C#.Pls mak it clear thanks

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

          The GridView's rows are not clickable by default. The only way to change that is to add javascript code for the onclick event to the rows. Even if you want to get the click event on the server because you need a postback to get to the server and you can only achieve is in javascript (at least in this scenario). So for server-side processing tha page needs to implement the IPostBackEventHandler interface add contain two method similiar to these:

          protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
          {
          e.Row.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(this, e.Row.ClientID));
          }

          public void RaisePostBackEvent(string eventArgument)
          {
          //the eventArgument will contain the ClientID of the row you clicked on, so you can
          //identify the row, if needed
          }

          K 1 Reply Last reply
          0
          • S szukuro

            The GridView's rows are not clickable by default. The only way to change that is to add javascript code for the onclick event to the rows. Even if you want to get the click event on the server because you need a postback to get to the server and you can only achieve is in javascript (at least in this scenario). So for server-side processing tha page needs to implement the IPostBackEventHandler interface add contain two method similiar to these:

            protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
            e.Row.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(this, e.Row.ClientID));
            }

            public void RaisePostBackEvent(string eventArgument)
            {
            //the eventArgument will contain the ClientID of the row you clicked on, so you can
            //identify the row, if needed
            }

            K Offline
            K Offline
            kidus1
            wrote on last edited by
            #5

            hi szukuro Thank you for yr information but the problem is the RaisePostBackEvent() can't be fired? Any info? kidus

            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