|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Allow paging
how to do allow paging and also allow custom paging in datagrid in asp.net?
|
|
#2
|
|||
|
|||
|
You have to set AllowPaging property of the DataGrid as true and in the code behind file use a DataDataGridPageChangedEventHandler
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEvent Args e) { DataGrid1.CurrentPageIndex = e.NewPageIndex; DataGrid1.DataBind(); } //Intitate private void InitializeComponent() { this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEvent Handler(this.DataGrid1_PageIndexChanged); this.Load += new System.EventHandler(this.Page_Load); } //IN PAGE LOAD private void Page_Load(object sender, System.EventArgs e) { cmd.Connection=shopObj.con; //Connection object cmd.CommandText="Select * from TABLENAME"; cmd.CommandType=CommandType.Text; SqlDataAdapter ad= new SqlDataAdapter(cmd.CommandText,shopObj.con); DataSet ds= new DataSet(); ad.Fill(ds); DataGrid1.DataSource=ds; DataGrid1.DataBind(); } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Allow paging |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|