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 row select

gridview row select

Scheduled Pinned Locked Moved ASP.NET
databasecomtoolshelpquestion
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.
  • S Offline
    S Offline
    Sunil Wise
    wrote on last edited by
    #1

    please look in to my problem yesterday i posted my query http://www.codeproject.com/script/comments/forums.asp?forumid=12076&mpp=50&fr=51&select=2330846#xx2330846xx[^]

    S 1 Reply Last reply
    0
    • S Sunil Wise

      please look in to my problem yesterday i posted my query http://www.codeproject.com/script/comments/forums.asp?forumid=12076&mpp=50&fr=51&select=2330846#xx2330846xx[^]

      S Offline
      S Offline
      Sun Rays
      wrote on last edited by
      #2

      Hi, go to MyArticles. It can help you.

      Thanks, Sun Rays Rate this post if you like answer. My Articles

      S 1 Reply Last reply
      0
      • S Sun Rays

        Hi, go to MyArticles. It can help you.

        Thanks, Sun Rays Rate this post if you like answer. My Articles

        S Offline
        S Offline
        Sunil Wise
        wrote on last edited by
        #3

        the main problem for me is select a row anyway i have done some thing like this if (e.Row.RowType == DataControlRowType.DataRow) {string alertBox = "alert(" + e.Row.RowIndex + ")"; //string alertBox = e.Row.RowIndex.ToString(); e.Row.Attributes.Add("Onclick", alertBox);} and i got the index of the row but i want the id of the row how can i get the id of the row can you please tell me in detail if possible with example regards sunilwise

        S 1 Reply Last reply
        0
        • S Sunil Wise

          the main problem for me is select a row anyway i have done some thing like this if (e.Row.RowType == DataControlRowType.DataRow) {string alertBox = "alert(" + e.Row.RowIndex + ")"; //string alertBox = e.Row.RowIndex.ToString(); e.Row.Attributes.Add("Onclick", alertBox);} and i got the index of the row but i want the id of the row how can i get the id of the row can you please tell me in detail if possible with example regards sunilwise

          S Offline
          S Offline
          Sun Rays
          wrote on last edited by
          #4

          Hi, to get SelectedRow you have to Create an event of TestGridView_SelectedIndexChanged. Here in this event you can get selected rowindex as well as any cell's value from selected row.

          Thanks, Sun Rays Rate this post if you like answer. My Articles

          S 1 Reply Last reply
          0
          • S Sun Rays

            Hi, to get SelectedRow you have to Create an event of TestGridView_SelectedIndexChanged. Here in this event you can get selected rowindex as well as any cell's value from selected row.

            Thanks, Sun Rays Rate this post if you like answer. My Articles

            S Offline
            S Offline
            Sunil Wise
            wrote on last edited by
            #5

            thank u ray for u r replies it helped me some what by the way i used javescript function and some code

            var gridViewCtlId = '<%=gvAuditErrors.ClientID%>';
            var gridViewCtl = null;
            var curSelRow = null;
            function getGridViewControl()
            {
                if (null == gridViewCtl)
                {
                    gridViewCtl = document.getElementById(gridViewCtlId);
                }
            }
            
            function onGridViewRowSelected(rowIdx)
            {
                var selRow = getSelectedRow(rowIdx);
                if (curSelRow != null)
                {
                    curSelRow.style.backgroundColor = '#ffffff';
                }
                
                if (null != selRow)
                {
                    curSelRow = selRow;
                    curSelRow.style.backgroundColor = '#99cccc';
                   alert(rowIdx); 
                }
            }
            
            function getSelectedRow(rowIdx)
            {
                getGridViewControl();
                if (null != gridViewCtl)
                {
                    return gridViewCtl.rows\[rowIdx\];
                   alert(rowIdx); 
                }
                return null;
            }
            

            private Int32 m_iRowIdx; protected void gvAuditErrors_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //string m_iRowIdx; e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + m_iRowIdx.ToString() + "')"); } m_iRowIdx++; } http://www.netomatix.com/Development/GridViewRowSelectedStyle.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