Labels

slider

Recent

Navigation

Pick Gridview row cell in ASP.Net

Gridview Row Cell, Gridview, Row Cell, Pick Gridview row cell in ASP.Net

Introduction

How to pick grid view row cell in asp.net, below is written code snippet to pick grid view row cell.

Protected Sub Grd_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Grd.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
For i As Integer = 0 To Grd.Columns.Count - 1
'e.Row.Cells(i).Attributes.Add("onclick", "FillValue('" + e.Row.Cells(i).ClientID & "')")
e.Row.Cells(i).Attributes.Add("onclick", "FillValue('" + e.Row.Cells(0).ClientID & "','" + e.Row.Cells(1).ClientID & "','" & e.Row.Cells(2).ClientID & "','" & e.Row.Cells(3).ClientID & "','" & e.Row.Cells(4).ClientID & "','" & e.Row.Cells(5).ClientID & "','" & e.Row.Cells(6).ClientID & "')")
Next
End If

End Sub


<code>
<script type="text/javascript">
function FillValue(cellId, GLAccountNumber, GLDescription, LineItemDescription, ProjectID, Amount, PaymentDetailID)
{
//alert('yes');
alert(cellId);
document.getElementById('txtID').value = document.getElementById(cellId).innerHTML;
document.getElementById('GLAccountNumber').value = document.getElementById(GLAccountNumber).innerHTML;
document.getElementById('GLDescription').value = document.getElementById(GLDescription).innerHTML;
document.getElementById('LineItemDescription').value = document.getElementById(LineItemDescription).innerHTML;
document.getElementById('ProjectID').value = document.getElementById(ProjectID).innerHTML;
document.getElementById('Amount').value = document.getElementById(Amount).innerHTML;
document.getElementById('PaymentDetailID').value = document.getElementById(PaymentDetailID).innerHTML;
}
<script/>
<code/>

Suggested Reading

Share

Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

0 comments: