Easy way to clear the DataGrid

J

Janaka

Is there a function to clear the Items out of the DataGrid or DataList? In
my page I want the user to be able to do different searches and before
rebinding the DataGrid, specify how many rows to display. Currently I am
hiding the grid by specifying Visible = false. However this still persits
all the Items in the viewstate. I do need viewstate when its bound though.
I was thinking it would be cleaner to delete the items from the Grid - is
this possible?
 
G

Gary K

I agree with Joel, in that I think that's part of what you need to do to
'clear' the grid. Have you tried limiting you're SQL results to the number
you want, all you need to add to the SELECT statement is add TOP x [PERCENT],
like so:

SELECT TOP 20 col1, col2 FROM table1; { returns the first 20 }
SELECT TOP 10 PERCENT col1, col2 FROM table1 ORDER BY col1; { returns the
first 10% of entries (ie, first 10 of 100) }

NOTE that due to it returning the FIRST entries, the ORDER BY clause becomes
very important.
 

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,797
Messages
2,569,647
Members
45,374
Latest member
VernitaBer

Latest Threads

Top