S
smithb1028
I have a simple DataGrid and trying to get paging to work. I
orginially want to use this in an AJAX UpdatePanel, but I moved it out
of it until I get it to work.
This is the DataGrid in the ASPX:
<asp
ataGrid ID="dgActiveVisits" AutoGenerateColumns="true"
AllowPaging="true" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChanged="dgActiveVisits_PageIndexChanged" runat="server">
<HeaderStyle BackColor="Gray"
ForeColor="White" />
</asp
ataGrid>
The C# code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dgActiveVisits.CurrentPageIndex = 0;
BindData();
}
}
protected void dgActiveVisits_PageIndexChanged(object sender,
DataGridPageChangedEventArgs e)
{
dgActiveVisits.CurrentPageIndex = e.NewPageIndex;
BindData();
}
void BindData()
{
DataTable dt = new DataTable();
// removed DataTable setup, has 15 rows
dgActiveVisits.DataSource = dt;
dgActiveVisits.DataBind();
}
When the page first loads, it loads the first page of data just fine.
But when I click Next, the entire DataGrid just disappears... At first
I thought there was an issue with the UpdatePanel, but after taking it
out of the UpdatePanel it still displays this same behavior... I
looked all over the internet and followed their examples exactly...
Any help would be greatly appreciated...
orginially want to use this in an AJAX UpdatePanel, but I moved it out
of it until I get it to work.
This is the DataGrid in the ASPX:
<asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
AllowPaging="true" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChanged="dgActiveVisits_PageIndexChanged" runat="server">
<HeaderStyle BackColor="Gray"
ForeColor="White" />
</asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
The C# code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dgActiveVisits.CurrentPageIndex = 0;
BindData();
}
}
protected void dgActiveVisits_PageIndexChanged(object sender,
DataGridPageChangedEventArgs e)
{
dgActiveVisits.CurrentPageIndex = e.NewPageIndex;
BindData();
}
void BindData()
{
DataTable dt = new DataTable();
// removed DataTable setup, has 15 rows
dgActiveVisits.DataSource = dt;
dgActiveVisits.DataBind();
}
When the page first loads, it loads the first page of data just fine.
But when I click Next, the entire DataGrid just disappears... At first
I thought there was an issue with the UpdatePanel, but after taking it
out of the UpdatePanel it still displays this same behavior... I
looked all over the internet and followed their examples exactly...
Any help would be greatly appreciated...