Datagrid pages do not work after select

S

sanjay

I am a newbie. On a button click, I use the following databind that works
perfectly. But after that no matter which page number I click at the bottom,
I always get the first page. The same happens with the column header clicks
to sort, reverse-sort, etc. How can I fix this? Thanks.


void btEntry_Click(object sender, EventArgs e) {

dataSrc.SelectCommand = "SELECT * FROM [visits] where visitedPage like
@anStr";

dataSrc.Parameters.Clear();

dataSrc.Parameters.Add("@anStr", srchBox.Text);

dataGrid.DataBind();

}
 
S

Scott M.

Where is your code to cause the new page of data to be loaded as well as
your code to cause the sort to happen? A DataGrid has properties like
"AllowSort" and "AllowPagining", but by turning these on, you don't
automatically get those features working. They just mean "allow the grid to
have this functionality", you still have to code that functionality.

A DataGrid has events corresponding to the page of data being changed
(PageIndexChanged I think) as well as a sort being initiated (SortCommand).
You need to write code in these events.
 
S

sanjay

Sorry, I realized that I am using webmatrix and mxdatagrid. It's not exactly
a datagrid and handles all paging, sorting by itself. Anyway, I have found a
solution where in page_load if it is a post back, I have to turn
AutoDataBind on and do a databind. That fixes the problem.

Thanks.
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top