Paging In GridView bound to DataSet

Paging In GridView bound to DataSet

Post by ES » Fri, 06 Oct 2006 06:37:39


Is there a reasonable way to implement paging in a GridView control that's
bound to a DataSet rather than a SqlDataSource? What needs to be done?

Thanks
 
 
 

Paging In GridView bound to DataSet

Post by ReyN » Fri, 06 Oct 2006 08:33:19


you don't have to change anything

paging will work in a GridView whether it's bound to SqlDataSource or a
DataSet

http://raven/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx

 
 
 

Paging In GridView bound to DataSet

Post by ReyN » Fri, 06 Oct 2006 08:37:39


ooops I posted the wrong link that's in my local host :) so here goes

http://www.yqcomputer.com/
 
 
 

Paging In GridView bound to DataSet

Post by ES » Fri, 06 Oct 2006 22:50:09

his is a multi-part message in MIME format.


Thanks for your reply.
I initially just bound the GridView to the DataSet, and ran it. It worked fine until I clicked a page number. At that point it gave me an error about the OnPageIndexChanging being raised but not handled, so I implemented it as such:
protected void gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e) {

gvSrchMatch.PageIndex = e.NewPageIndex;

}

This runs, but does not page correctly. The help file on this event speaks of canceling the move to the next page, but not actually making the control move to the next page.

Interestingly, your demo crashes when you click a page link...

Elton

"ReyN" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Thanks for your reply.</FONT></DIV>
<DIV><FONT face=Arial size=2>I initially just bound the GridView to the DataSet,
and ran it.  It worked fine until I clicked a page number.  At that
point it gave me an error about the OnPageIndexChanging being raised but not
handled, so I implemented it as such:</FONT></DIV>
<DIV>
<P><FONT face="Courier New" color=#000080 size=2>protected void
gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e)
{</FONT></P>
<P><FONT face="Courier New" color=#000080 size=2>   
gvSrchMatch.PageIndex = e.NewPageIndex;</FONT></P>
<P><FONT face="Courier New" color=#000080 size=2>}</FONT></P>
<P><FONT face=Arial size=2>This runs, but does not page correctly.  The
help file on this event speaks of canceling the move to the next page, but not
actually making the control move to the next page.</FONT></P>
<P><FONT face=Arial size=2>Interestingly, your demo crashes when you click a
page link...</FONT></P>
<P><FONT face="Courier New" size=2>Elton</FONT></P></DIV>
<DIV><FONT face="Courier New" size=2>"ReyN" <</FONT><A
href="mailto: XXXX@XXXXX.COM "><FONT face="Courier New"
size=2> XXXX@XXXXX.COM </FONT></A><FONT face="Courier New" size=2>> wrote
in message </FONT><A
href="news: XXXX@XXXXX.COM "><FONT
face="Courier New"
size=2>news: XXXX@XXXXX.COM </FONT></A><FONT
face="Courier New" size=2>...</FONT></DIV><FONT face="Courier New" size=2>>
<BR>> ooops I posted the wrong link that's in my local host :) so here
goes<BR>> <BR>> </FONT><A
href="http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx"><FONT
face="Courier New"
size=2>http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx</FONT></A><BR><FONT
face="Courier New" size=2>></FONT></BODY></HTML>

 
 
 

Paging In GridView bound to DataSet

Post by ReyN » Sat, 07 Oct 2006 18:11:26


you have to rebind the GridView after setting the PageIndex in the
event handler
 
 
 

Paging In GridView bound to DataSet

Post by ES » Thu, 12 Oct 2006 02:36:49

This is a multi-part message in MIME format.


Thanks, I repopulated the grid, set the index, and bound and it appears to work. I think caching the dataset might make it more efficient. It seems wrong to get the whole dataset each time...

protected void gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e) {

gvSrchMatch.DataSource = PvrProfile.GetMatches(txtSrchLastName.Text);

gvSrchMatch.PageIndex = e.NewPageIndex;

gvSrchMatch.DataBind();

}



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face="Courier New" size=2>Thanks,  I repopulated the grid, set
the index, and bound and it appears to work.  I think caching the dataset
might make it more efficient.  It seems wrong to get the whole dataset each
time...</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT size=2>
<P></FONT><FONT face="Courier New"><FONT color=#0000ff
size=2>protected</FONT><FONT size=2> </FONT><FONT color=#0000ff
size=2>void</FONT><FONT size=2> gvSrchMatch_PageIndexChanging(</FONT><FONT
color=#0000ff size=2>object</FONT><FONT size=2> sender, </FONT><FONT
color=#008080 size=2>GridViewPageEventArgs</FONT></FONT><FONT size=2><FONT
face="Courier New"> e) {</FONT></P>
<P><FONT face="Courier New">    gvSrchMatch.DataSource =
</FONT></FONT><FONT face="Courier New" color=#008080
size=2>PvrProfile</FONT><FONT size=2><FONT
face="Courier New">.GetMatches(txtSrchLastName.Text);</FONT></P>
<P><FONT face="Courier New">    gvSrchMatch.PageIndex =
e.NewPageIndex;</FONT></P>
<P><FONT face="Courier New">   
gvSrchMatch.DataBind();</FONT></P>
<P><FONT face="Courier New">}</FONT></P></FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>"ReyN" <</FONT><A
href="mailto: XXXX@XXXXX.COM "><FONT face="Courier New"
size=2> XXXX@XXXXX.COM </FONT></A><FONT face="Courier New" size=2>> wrote
in message </FONT><A

face="Courier New"

face="Courier New" size=2>...</FONT></DIV><FONT face="Courier New" size=2>>
<BR>> you have to rebind the GridView after setting the PageIndex in
the<BR>> event handler<BR>></FONT></BODY></HTML>