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