JQuery:How
to get GridView Cell Data in ASP.NET using C#/VB.NET
In C#:
using System.Data;
public partial class GetGridCellData : System.Web.UI.Page
{
protected
void Page_Load(object
sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
protected
void BindGridData()
{
DataTable dt = new
DataTable();
dt.Columns.AddRange(new DataColumn[2]
{ new DataColumn("EMP ID"), new
DataColumn("EMP
Name") });
dt.Rows.Add("1", "Kishore");
dt.Rows.Add("2", "Roja");
dt.Rows.Add("3", "Satyam");
dt.Rows.Add("4", "Raghava");
dt.Rows.Add("5", "Nag");
dt.Rows.Add("6", "Krishna");
dt.Rows.Add("7", "Purna
Anil");
dt.Rows.Add("8", "Sowji");
dt.Rows.Add("9",
"Abhi");
dt.Rows.Add("10", "Sreenu");
dt.Rows.Add("11", "Ashok");
dt.Rows.Add("12", "Sathish");
dt.Rows.Add("13", "Purna");
gv_GetCellData.DataSource = dt;
gv_GetCellData.DataBind();
}
}
|
In VB.NET:
Imports System.Data
Partial Public Class GetGridCellData
Inherits
System.Web.UI.Page
Protected
Sub Page_Load(ByVal
sender As Object,
ByVal e As EventArgs)
If Not IsPostBack Then
BindGridData()
End If
End
Sub
Protected
Sub BindGridData()
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn(1)
{New DataColumn("EMP ID"), New
DataColumn("EMP
Name")})
dt.Rows.Add("1", "Kishore")
dt.Rows.Add("2", "Roja")
dt.Rows.Add("3", "Satyam")
dt.Rows.Add("4", "Raghava")
dt.Rows.Add("5", "Nag")
dt.Rows.Add("6", "Krishna")
dt.Rows.Add("7", "Purna
Anil")
dt.Rows.Add("8", "Sowji")
dt.Rows.Add("9", "Abhi")
dt.Rows.Add("10", "Sreenu")
dt.Rows.Add("11", "Ashok")
dt.Rows.Add("12", "Sathish")
dt.Rows.Add("13", "Purna")
gv_GetCellData.DataSource = dt
gv_GetCellData.DataBind()
End
Sub
End Class
|
Output:
No comments:
Post a Comment