Skip to content

Instantly share code, notes, and snippets.

@corespider
Created February 26, 2022 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corespider/fd74db44242eb97326d0c6da2b39e16e to your computer and use it in GitHub Desktop.
Save corespider/fd74db44242eb97326d0c6da2b39e16e to your computer and use it in GitHub Desktop.
How to Bind Array to GridView in ASP.Net
//Tow Dimensional Array
string[,] arr2D = {
{ "Ram", "India" },
{ "John", "USA" },
{ "Stewart", "UK" },
{ "Sham", "India"},
{ "Tod","USA" },
{ "Bryan","Russia" }
};
ArrayList arrList = new ArrayList();
for (int i = 0; i < 5; i++)
{
arrList.Add(new ListItem(arr2D[i, 0], arr2D[i, 1]));
}
gridView2.DataSource = arrList;
gridView2.DataBind();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment