DataGrid Custom Paging Problem

G

Guest

I have aspx page with user control , in the user control i have DataGrid with
custom paging the grid is displaying contents of datatable as following
schema
[ schema fragment]
<xs:element name="id" type="xs:string" minOccurs="0" />
<xs:element name="size" type="xs:int" minOccurs="0" />
<xs:element name="filesize" type="xs:long" minOccurs="0" />
<xs:element name="date" type="xs:dateTime" minOccurs="0" />
<xs:element name="sendername" type="xs:string" minOccurs="0" />
<xs:element name="senderemail" type="xs:string" minOccurs="0" />
<xs:element name="subject" type="xs:string" minOccurs="0" />
<xs:element name="forwarded" type="xs:boolean" minOccurs="0" />
<xs:element name="replayed" type="xs:boolean" minOccurs="0" />
<xs:element name="hasattachment" type="xs:boolean" minOccurs="0" />
<xs:element name="importance" type="xs:boolean" minOccurs="0" />
<xs:element name="seen" type="xs:boolean" minOccurs="0" />
<xs:element name="type" type="xs:string" minOccurs="0" />

inside the function showInbox() that bind the datatable to datagrid

void showInbox()
{
....
int msgcont = oMH.MessagesCount;

if(msgcont <= 0)
{
//Display some messages
return;
}
// Set the View
divInbox.Visible = true;
NoMsg.Visible = false;

// Set the Paging of the Grid
IStart = msgcont - (PageNumber * PageSize) + 1;
IEnd = IStart+PageSize-1;
// The Next and Previous Links
String NextLink = String.Format("<a href={0}
onmouseover=\"MM_swapImage('Next','','MailTools/Images/B_Next_O.jpg',1)\"
onmouseout=MM_swapImgRestore()><img ID='Next'
src='mailtools/Images/B_Next.jpg' align='center' border=0
<a>",Page.GetPostBackClientHyperlink(lbtnAction ,"next,"+(PageNumber + 1)));
String PreviousLink = String.Format("<a href={0}
onmouseover=\"MM_swapImage('Previous','','MailTools/Images/B_Previous_O.jpg',1)\"
onmouseout=MM_swapImgRestore()><img ID='Previous'
src='mailtools/Images/B_Previous.jpg' align='center'
border=0><a>",Page.GetPostBackClientHyperlink(lbtnAction, "Previous," +
(PageNumber - 1)));
if(IStart <= 1)
{
//no next
IStart = 1;
NextLink = "";
}
if(IEnd >= msgcont)
{
//no prives
PreviousLink = "";
}

// Bin the Data
DataTable dtMessages = oMH.GetAllMessages(IStart,IEnd) ;

DataView gridsort = dtMessages.DefaultView;
gridsort.Sort = SortString;
dgInbox.DataSource = gridsort;
dgInbox.DataBind();
}

I set the page size = 20 , so the problem i have the item is not sorted
properly ,that if i have 23 items in datagrid , first page has 20 items
sorted well , but second page has items with new dates than the last items in
first page ( mean in first page u can find sorted in desc dates from 2005 -
down to 2003) click next page u will find date with 2005 ) . what u suggested
to do in this case?

Hope i explain the problem well
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top