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_RowCreated event handler is not working on GridView_PageIndexChanging

GridView_RowCreated event handler is not working on GridView_PageIndexChanging

Scheduled Pinned Locked Moved ASP.NET
javajavascripttoolshelp
3 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.
  • M Offline
    M Offline
    Member 2998969
    wrote on last edited by
    #1

    My evet handler is this protected void GV_Main_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + m_iRowIdx.ToString() + "')"); } m_iRowIdx++; } Which perform a selected row color change.This call a java script Which is like this < script language="javascript" type="text/javascript> var gridViewCtlId = '<%=GV_Main.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'; curSelRow.style.backgroundColor = ''; } if (null != selRow) { curSelRow = selRow; //curSelRow.style.backgroundColor = '#ff0022'; curSelRow.style.backgroundColor = '#D1DDF1'; } } function getSelectedRow(rowIdx) { getGridViewControl(); if (null != gridViewCtl) { return gridViewCtl.rows[rowIdx]; } return null; } When a run application on dafault page 1 it is work fine ,but as I change page is is not working .Grigview use paging Please tell me my error or give me a solution. Thanks

    adilkhan

    V 1 Reply Last reply
    0
    • M Member 2998969

      My evet handler is this protected void GV_Main_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + m_iRowIdx.ToString() + "')"); } m_iRowIdx++; } Which perform a selected row color change.This call a java script Which is like this < script language="javascript" type="text/javascript> var gridViewCtlId = '<%=GV_Main.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'; curSelRow.style.backgroundColor = ''; } if (null != selRow) { curSelRow = selRow; //curSelRow.style.backgroundColor = '#ff0022'; curSelRow.style.backgroundColor = '#D1DDF1'; } } function getSelectedRow(rowIdx) { getGridViewControl(); if (null != gridViewCtl) { return gridViewCtl.rows[rowIdx]; } return null; } When a run application on dafault page 1 it is work fine ,but as I change page is is not working .Grigview use paging Please tell me my error or give me a solution. Thanks

      adilkhan

      V Offline
      V Offline
      VijayVishwakarma
      wrote on last edited by
      #2

      can you tell me if your gridview is in content placeholder? If yes, Check the page source to find the id of the gridview. If u are using content placeholder, then the id of the gridview will change to ctl_01_gridview or something. So the javascript is not able to find the gridview. Check this first.

      Vijay V. Yash Softech

      M 1 Reply Last reply
      0
      • V VijayVishwakarma

        can you tell me if your gridview is in content placeholder? If yes, Check the page source to find the id of the gridview. If u are using content placeholder, then the id of the gridview will change to ctl_01_gridview or something. So the javascript is not able to find the gridview. Check this first.

        Vijay V. Yash Softech

        M Offline
        M Offline
        Member 2998969
        wrote on last edited by
        #3

        thanks to gave me a solution . yes this in content placeholder but i alert this ID,its alert fine once when default page occrue.ut as i click on on next page of GridView alert is not fired ,means that second time java script not call.

        adilkhan

        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