HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvMultiDimensionalArray" runat="server" Width="500px" AutoGenerateColumns="False"
CellPadding="3" GridLines="None" BackColor="White" BorderColor="White"
BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1">
<Columns>
<asp:BoundField DataField="StudentName" HeaderText="StudentName" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="StudentAddress" HeaderText="Address" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Phone" HeaderText="Phone" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />
</asp:GridView>
</div>
</form>
</body>
</html>
CODE BEHIND
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 TestDesign_MultidimentionalArrays : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridview();
}
}
private void BindGridview()
{
string[,] StudentName = {
{"Fuzlul Roman","Chandpur","01815675184"},
{"Iqbal Hossain","Noakhali","01815675164"},
{"Jabed Hossain","Lakipur","01815695164"},
{"Noor Mohammad","Rajsahi","01815695164"}
,{"Khorshed Alam","Narayangonj","01815695164"}
,{"Mizanur Rahman","Pabna","01815695164"}
};
DataTable dt = new DataTable();
dt.Columns.Add("StudentName");
dt.Columns.Add("StudentAddress");
dt.Columns.Add("Phone");
//dt.WriteXml();
for (int i = 0; i <StudentName.GetLength(0); i++)
{
dt.Rows.Add();
dt.Rows[i]["StudentName"] = StudentName[i,0].ToString();
dt.Rows[i]["StudentAddress"] = StudentName[i,1].ToString();
dt.Rows[i]["Phone"] = StudentName[i, 2].ToString();
}
gvMultiDimensionalArray.DataSource = dt;
gvMultiDimensionalArray.DataBind();
}
}