<asp:GridView ID="Studentlist" CssClass="Grid" runat="server"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None" Width ="55%" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="StudentName" HeaderText="StudentName" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:BoundField DataField="Phone" HeaderText="Phone" />
<asp:BoundField DataField="JoingDate" HeaderText="JoingDate" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class StoreDataTableValueinSession : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["StudentList"] = GetStudentList();
Studentlist.DataSource = Session["StudentList"];
Studentlist.DataBind();
}
static DataTable GetStudentList()
{
//Created virtual data Storage
DataTable table = new DataTable();
table.Columns.Add("StudentName", typeof(string));
table.Columns.Add("Address", typeof(string));
table.Columns.Add("Phone", typeof(string));
table.Columns.Add("JoingDate", typeof(DateTime));
// Now have created some row to fill the the datatable
table.Rows.Add("Samima Nasim", "Dhaka", "01856587548", "11/5/2010");
table.Rows.Add("Ahsanul Kabir", "Chittagong", "01856587548", "12/ 5/2204");
table.Rows.Add("Nirub Ashasan", "Sylhet", "01856587544", "11/10/ 2008");
table.Rows.Add("Zaman Ahmed", "Rajsahi", "01856587878", "11 /15/ 2003");
table.Rows.Add("Habibur Rahman", "Barisal", "01856587548", "11 /5 / 2010");
return table;
}
}