NameDescriptionEmailPhone
MaxHello my name is Max and I am software engineer.Demo@Gmail.comMy Phone is 123456789
AlbertHello my name is Albert and I am software engineer.Demo@Gmail.comMy Phone is 123456789
DestinHello my name is Destin and I am software engineer.Demo@Gmail.comMy Phone is 123456789
JessieHello my name is Jessie and I am software engineer.Demo@Gmail.comMy Phone is 123456789
JoeHello my name is Joe and I am software engineer.Demo@Gmail.comMy Phone is 123456789
DillonHello my name is Dillon and I am software engineer.Demo@Gmail.comMy Phone is 123456789
AldoHello my name is Aldo and I am software engineer.Demo@Gmail.comMy Phone is 123456789
PeterHello my name is Peter and I am software engineer.Demo@Gmail.comMy Phone is 123456789
OwenHello my name is Owen and I am software engineer.Demo@Gmail.comMy Phone is 123456789
OrionHello my name is Orion and I am software engineer.Demo@Gmail.comMy Phone is 123456789
1234

GridView

    

CSS

     
    

Code Behind

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bindDataToGridView();
        }
    }

    public void bindDataToGridView()
    {
        DataTable dt = new DataTable();
        DataColumn dc = new DataColumn();
        dc.ColumnName = "Name";
        dc.DataType = typeof(string);
        dt.Columns.Add(dc);

        dc = new DataColumn();
        dc.ColumnName = "Description";
        dc.DataType = typeof(string);
        dt.Columns.Add(dc);

        dc = new DataColumn();
        dc.ColumnName = "Email";
        dc.DataType = typeof(string);
        dt.Columns.Add(dc);

        dc = new DataColumn();
        dc.ColumnName = "Phone";
        dc.DataType = typeof(string);

        dt.Columns.Add(dc);

        dt.Rows.Add(new object[] { "Max", "Hello my name is Max and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Albert", "Hello my name is Albert and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Destin", "Hello my name is Destin and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Jessie", "Hello my name is Jessie and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Joe", "Hello my name is Joe and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Dillon", "Hello my name is Dillon and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Aldo", "Hello my name is Aldo and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Peter", "Hello my name is Peter and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Owen", "Hello my name is Owen and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Orion", "Hello my name is Orion and I am software engineer.", "Demo@Gmail.com", "My Phone is 123456789" });

        dt.Rows.Add(new object[] { "Max222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Albert222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Destin222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Jessie222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Joe222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Dillon222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Aldo222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Peter222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Owen222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Orion222", "This is page 2 This is page 2 This is page 2 This is page 2", "Demo@Gmail.com", "My Phone is 123456789" });

        dt.Rows.Add(new object[] { "Max333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Albert333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Destin333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Jessie333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Joe333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Dillon333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Aldo333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Peter333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Owen333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Orion333", "This is page 3 This is page 3 This is page 3 This is page 3", "Demo@Gmail.com", "My Phone is 123456789" });

        dt.Rows.Add(new object[] { "Max444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Albert444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Destin444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Jessie444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Joe444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Dillon444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Aldo444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Peter444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Owen444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });
        dt.Rows.Add(new object[] { "Orion444", "This is page 4 This is page 4 This is page 4 This is page 4", "Demo@Gmail.com", "My Phone is 123456789" });

        grdTest.DataSource = dt;
        grdTest.DataBind();

    }



    protected void grdTest_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdTest.PageIndex = e.NewPageIndex;
        bindDataToGridView();
    }
    

Back to Article

About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2019 CodingFusion
75 Important SQL Server queries you should know