I am having a problem with my DataGrid paging correctly...for some reason it
always stays on the same page when I click on the "<" or ">". Can you tell
where I am going wrong in the code? I've taken a good stare at this for
several hours and was hoping someone would notice that little tiny line that
I am not.
Thanks in advance, says the C# noob (me, hehe).
Here's the code:
public partial class EmployeeDirectory : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
getEmployeeDirectory();
}
}
protected void getEmployeeDirectory()
{
using (SqlConnection dbConn = clsDatabase.dbOpen())
{
// Create an SqlDataAdapter object using the SqlConnection object
SqlDataAdapter dbData = new SqlDataAdapter("some SQL statement",
dbConn);
// Create a DataSet object that will be used as a placeholder
for our query data
DataSet dsEmployeeDirectory = new DataSet();
dbData.Fill(dsEmployeeDirectory);
// Bind query data to our DataList object
dgEmployeeDirectory.DataSource = dsEmployeeDirectory;
dgEmployeeDirectory.DataBind();
}
}
protected void dgEmployeeDirectory_PageIndexChanged(object source,
DataGridPageChangedEventArgs e)
{
dgEmployeeDirectory.CurrentPageIndex = e.NewPageIndex;
getEmployeeDirectory();
}
}
|