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="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<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>
</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>
</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"},
{"Iqbal Hossain","Noakhali"},
{"Jabed Hossain","Lakipur"},
{"Noor Mohammad","Rajsahi"}
,{"Khorshed Alam","Narayangonj"}
};
DataTable dt = new DataTable();
dt.Columns.Add("StudentName");
dt.Columns.Add("StudentAddress");
//dt.WriteXml();
for (int i = 0; i <5; i++)
{
dt.Rows.Add();
dt.Rows[i]["StudentName"] = StudentName[i,0].ToString();
dt.Rows[i]["StudentAddress"] = StudentName[i,1].ToString();
}
gvMultiDimensionalArray.DataSource = dt;
gvMultiDimensionalArray.DataBind();
}
}