8 June 2013

array list to a gridview.

Asp.net code:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <center>
        <asp:GridView ID="gv1" runat="server">
        </asp:GridView>
    </center>
</asp:Content>

C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int[] arrayobj = { 1, 2, 3, 4, 5, 6, 7, 8 };

            gv1.DataSource = arrayobj;

           gv1.DataBind();

    }
}

Output:

No comments:

Post a Comment