script_calling ?
-
var gridViewCtlId = '<%=gridview1.ClientID%>'; var gridViewCtl = null; var curSelRow = null; var curRowIdx = -1; function getGridViewControl() { if (null == gridViewCtl) { gridViewCtl = document.getElementById(gridViewCtlId); } } function onGridViewRowSelected(rowIdx) { var selRow = getSelectedRow(rowIdx); if (null != selRow) { curSelRow = selRow; var cellValue = getCellValue(rowIdx, 0); alert(cellValue); } } function getSelectedRow(rowIdx) { return getGridRow(rowIdx); } function getGridRow(rowIdx) { getGridViewControl(); if (null != gridViewCtl) { return gridViewCtl.rows[rowIdx]; } return null; } function getGridColumn(rowIdx, colIdx) { var gridRow = getGridRow(rowIdx); if (null != gridRow) { return gridRow.cells[colIdx]; } return null; } function getCellValue(rowIdx, colIdx) { var gridCell = getGridColumn(rowIdx, colIdx); if (null != gridCell) { alert(gridViewCtlId) return gridCell.innerText; } return null; } I i call it as: For Each row As GridViewRow In GridView1.Rows CType(row.FindControl("Textbox1"), TextBox).Attributes("onclick") = "javascript: return getCellValue(0,1)" it works... But how to pass dynamic value in place of 0 and 1 <div class="ForumSig">sanjay kumar samantaray</div></x-turndown>
-
var gridViewCtlId = '<%=gridview1.ClientID%>'; var gridViewCtl = null; var curSelRow = null; var curRowIdx = -1; function getGridViewControl() { if (null == gridViewCtl) { gridViewCtl = document.getElementById(gridViewCtlId); } } function onGridViewRowSelected(rowIdx) { var selRow = getSelectedRow(rowIdx); if (null != selRow) { curSelRow = selRow; var cellValue = getCellValue(rowIdx, 0); alert(cellValue); } } function getSelectedRow(rowIdx) { return getGridRow(rowIdx); } function getGridRow(rowIdx) { getGridViewControl(); if (null != gridViewCtl) { return gridViewCtl.rows[rowIdx]; } return null; } function getGridColumn(rowIdx, colIdx) { var gridRow = getGridRow(rowIdx); if (null != gridRow) { return gridRow.cells[colIdx]; } return null; } function getCellValue(rowIdx, colIdx) { var gridCell = getGridColumn(rowIdx, colIdx); if (null != gridCell) { alert(gridViewCtlId) return gridCell.innerText; } return null; } I i call it as: For Each row As GridViewRow In GridView1.Rows CType(row.FindControl("Textbox1"), TextBox).Attributes("onclick") = "javascript: return getCellValue(0,1)" it works... But how to pass dynamic value in place of 0 and 1 <div class="ForumSig">sanjay kumar samantaray</div></x-turndown>
What dynamic values do you want to pass instead of 0 and 1? Please be more specific when phrasing a question. If the first argument to your javascript function needs to change with each iteration of the loop, get the index of the current row by referencing the RowIndex property of your row object and insert it into your attribute string. For instance:
CType(row.FindControl("Textbox1"), TextBox).Attributes("onclick") = "javascript: return getCellValue(" + row.RowIndex.ToString() + ",1)"
Do something similar if you need to change the column index dynamically. Paul
-
What dynamic values do you want to pass instead of 0 and 1? Please be more specific when phrasing a question. If the first argument to your javascript function needs to change with each iteration of the loop, get the index of the current row by referencing the RowIndex property of your row object and insert it into your attribute string. For instance:
CType(row.FindControl("Textbox1"), TextBox).Attributes("onclick") = "javascript: return getCellValue(" + row.RowIndex.ToString() + ",1)"
Do something similar if you need to change the column index dynamically. Paul
Thanx for your reply. Now i am getting only the column heading of 2nd column. how could i display each cell's value of 2nd column. Dialog box appears without any text. Thanx . -- modified at 2:05 Saturday 1st September, 2007
sanjay kumar samantaray
-
Thanx for your reply. Now i am getting only the column heading of 2nd column. how could i display each cell's value of 2nd column. Dialog box appears without any text. Thanx . -- modified at 2:05 Saturday 1st September, 2007
sanjay kumar samantaray