D
David A. Coursey
This code works if I don't use paging, but then I get a mile long page. As
soon as I put in paging it throws the error:
AllowCustomPaging must be true and VirtualItemCount must be set for a
DataGrid with ID dgWebLog when AllowPaging is set to true and the selected
datasource does not implement ICollection.
I have seen this before, and always fixed it by using a DataSet to fill the
grid instead of a DataReader. But now I use this Database Access Class that
I found online that works great, but uses a DataReader. Is there anything I
can do to still use a DataReader?
Anyhoo, here is my code:
protected void bindWebLogData(string login)
{
DataSet ds = new DataSet();
SqlDataReader dataReader = null;
Database data = new Database();
try
{
SqlParameter[] prams = {data.MakeInParam("@login" ,SqlDbType.VarChar,
75, login)};
data.RunProc("cma_getWebLogData", prams, out dataReader);
}
catch(Exception ex)
{
string errorMessage = "";
Exception curEx = ex;
while (curEx != null)
{
//collect all inner exceptions
errorMessage += curEx.Message + "\n";
curEx = curEx.InnerException;
}
//throw a new exception with errorMessage as it's message
throw new Exception(errorMessage);
}
finally
{
if (dataReader.HasRows)
{
dataReader.Read();
dgWebLog.DataSource = dataReader;
dgWebLog.DataBind();
}
}
}
Thanks for your help
David A. Coursey
soon as I put in paging it throws the error:
AllowCustomPaging must be true and VirtualItemCount must be set for a
DataGrid with ID dgWebLog when AllowPaging is set to true and the selected
datasource does not implement ICollection.
I have seen this before, and always fixed it by using a DataSet to fill the
grid instead of a DataReader. But now I use this Database Access Class that
I found online that works great, but uses a DataReader. Is there anything I
can do to still use a DataReader?
Anyhoo, here is my code:
protected void bindWebLogData(string login)
{
DataSet ds = new DataSet();
SqlDataReader dataReader = null;
Database data = new Database();
try
{
SqlParameter[] prams = {data.MakeInParam("@login" ,SqlDbType.VarChar,
75, login)};
data.RunProc("cma_getWebLogData", prams, out dataReader);
}
catch(Exception ex)
{
string errorMessage = "";
Exception curEx = ex;
while (curEx != null)
{
//collect all inner exceptions
errorMessage += curEx.Message + "\n";
curEx = curEx.InnerException;
}
//throw a new exception with errorMessage as it's message
throw new Exception(errorMessage);
}
finally
{
if (dataReader.HasRows)
{
dataReader.Read();
dgWebLog.DataSource = dataReader;
dgWebLog.DataBind();
}
}
}
Thanks for your help
David A. Coursey