Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace logindemo
{
    public partial class Welcometo : System.Web.UI.Page
    {
        private SqlConnection conn = new SqlConnection("Data Source=INFND-DTP-0222;Initial Catalog=Test_DB;User ID=alok;Password=a12343");

        protected void Page_Load(object sender, EventArgs e)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand("Select * from login", conn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            conn.Close();
            GridView1.DataSource = ds;
            GridView1.DataBind();

        }



        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }
    }
}
Posted
Updated 16-Mar-15 19:01pm
v2

1 solution

Please Page Index Changing Event ...
for Example:
C#
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    LoadGridData();       // It's a function to load data
}


for Help Follow below links .
How To Implement Paging in GridView Control in ASP.NET[^]

http://www.c-sharpcorner.com/UploadFile/rohatash/gridview-paging-sample-in-Asp-Net/[^]
 
Share this answer
 
Comments
Divyam Sharma 17-Mar-15 0:46am    
good one...
.net bigner 17-Mar-15 1:16am    
Thanx..But when i write that code, that is showing a red line bellow the NewpageIndex nad LoadGridData();
What is the error?
aarif moh shaikh 17-Mar-15 1:44am    
It's a user defined function... Don't use it and give datasource to your grid view .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900