Posted by : Anwar Hossain
Category : How to use grid view in c#

How to bind Multi-Dimensional Arrays Data to gird view in using C#

Dear Viewers I will show how to bind Multi -Dimensional Arrays .In this case first I have created string type Multi -Dimensional Arrays Then I have also assigned the values to arrays. A data table is used to create virtual table .After creating data table I have passed the arrays values to the data table using for loop. Finally I have assigned the data table value to the grid view.

Bind Multi -Dimensional Arrays in ASP.NET C#


<html xmlns="">
<head runat="server">
  <form id="form1" runat="server">
  <asp:GridView ID="gvMultiDimensionalArray" runat="server" Width="500px" AutoGenerateColumns="False"
  CellPadding="3" GridLines="None" BackColor="White" BorderColor="White"
  BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1">
  <asp:BoundField DataField="StudentName" HeaderText="StudentName" ItemStyle-HorizontalAlign="Center">
  <ItemStyle HorizontalAlign="Center"></ItemStyle>
  <asp:BoundField DataField="StudentAddress" HeaderText="Address" ItemStyle-HorizontalAlign="Center">
  <ItemStyle HorizontalAlign="Center"></ItemStyle>
  <asp:BoundField DataField="Phone" HeaderText="Phone" ItemStyle-HorizontalAlign="Center">
  <ItemStyle HorizontalAlign="Center"></ItemStyle>
  <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" />


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)
  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();
  for (int i = 0; i <StudentName.GetLength(0); i++)
  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;

Out Put


Realted Article Headline

Gridview datetime format example in ASP.Net c#
Displaying total column value in the Gridview Footer using c#.
How to create grid view paging in using c#
How to bind Multi-Dimensional Arrays Data to gird view in using C#
How to bind Two-Dimensional Arrays Data to gird view in using C#
How to bind Single-Dimensional Arrays Data to gird view in using C#
how to export gridview data to pdf in c#
how to export gridview data to word in using c#
how to export gridview data to excel in c#
How to delete row from grid view showing confirmation JavaScript using c#
How to delete data from grid view using row deleting event in c#
How to bind data into gridview using code behind in c#
How to scroll gird view overflow data in c#
How to Bind data into grid view control using c#

Article Category

How to create control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C# c # basic tutorial
How to use ajax toolkit in C#
How to use different types of validation control using c#
How to use grid view in c#
Protected by Copyscape Online Plagiarism Detection