Why is my Paging not working in my DataGrid?

A

Anonieko Ramos

Question: Why can't I enable paging in Datagrid?
Answer:
You must check 'AllowPaging'

You must add code to handle the PageIndexChanged Event.

This is the partial code...

// If you have dragged and dropped the oracle connection to
design surface,
// the InitializeComponent() will create the following.
// 1. Connection
// 2. Adapter
// 3. Adapter's Delete, Insert, Update commands.
//

private void DataGrid1_Load(object sender, System.EventArgs e)
{
if ( ! Page.IsPostBack )
{
// First Time
BindData();
}
}

private void BindData()
{
oracleConnection1.Open();
DataSet ds = new DataSet();
oracleDataAdapter1.Fill(ds, "AccountDomain");
DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
oracleConnection1.Close();

}

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top