using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;//
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace SampleCS
{
public class 기본페이징테스트 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack){
ReadData();
}
}
private void ReadData(){
SqlConnection objCon = new SqlConnection(
"server=(local);database=Sample;uid=Sample;pwd=Sample");
objCon.Open();
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objCon;
objCmd.CommandText =
"Select * From PagingTest Order By Num Desc";
objCmd.CommandType = CommandType.Text;
SqlDataAdapter objDa = new SqlDataAdapter();
objDa.SelectCommand = objCmd;
DataSet objDs = new DataSet();
objDa.Fill(objDs, "PagingTest");
this.DataGrid1.DataSource = objDs;
this.DataGrid1.DataBind();
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
ReadData();
}
}
}