T
tshad
If you have an ObjectDataSource and are using it to do the Page Count - it
calls a method that querys the database to get this number.
The problem is that everytime the user presses the page control at the
bottom of the grid to get the next page or another page, it calls this
method again.
<asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"
runat="server" SelectCountMethod="GetRowCount"
SelectMethod="BindControl" TypeName="DAO"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows">
</asp:ObjectDataSource>
In this case it calls SelectCountMethod (GetRowCount) each time a user wants
a new page.
In my DAO object, my method looks like:
public int GetRowCount()
{
// int id;
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["ConnectString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand("GetDetailsRowCount", con);
com.CommandType = CommandType.StoredProcedure;
SqlDataReader dr = com.ExecuteReader();
int count = 0;
while (dr.Read())
{
if (dr["NumberOfRows"] != null)
int.TryParse(dr["NumberOfRows"].ToString(), out count);
}
return count;
}
The problem is that this method is called from the ObjectDataSource each
time a user wants a new page which means a new trip to the database to get
the number I already got the first time around.
You can't seem to store the number in the object as the DAO object is
created each time you get the next page.
Is there a way to tell the ODS to use the same number it had the first time
around?
Thanks,
Tom
calls a method that querys the database to get this number.
The problem is that everytime the user presses the page control at the
bottom of the grid to get the next page or another page, it calls this
method again.
<asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"
runat="server" SelectCountMethod="GetRowCount"
SelectMethod="BindControl" TypeName="DAO"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows">
</asp:ObjectDataSource>
In this case it calls SelectCountMethod (GetRowCount) each time a user wants
a new page.
In my DAO object, my method looks like:
public int GetRowCount()
{
// int id;
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["ConnectString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand("GetDetailsRowCount", con);
com.CommandType = CommandType.StoredProcedure;
SqlDataReader dr = com.ExecuteReader();
int count = 0;
while (dr.Read())
{
if (dr["NumberOfRows"] != null)
int.TryParse(dr["NumberOfRows"].ToString(), out count);
}
return count;
}
The problem is that this method is called from the ObjectDataSource each
time a user wants a new page which means a new trip to the database to get
the number I already got the first time around.
You can't seem to store the number in the object as the DAO object is
created each time you get the next page.
Is there a way to tell the ODS to use the same number it had the first time
around?
Thanks,
Tom