On Jul 15, 5:45*pm, Dan <D...@discussions.microsoft.comwrote:
I am reposting a question from about 3 weeks ago ("sorting capability").
I have an aspx page in which I get the data from a database dynamically,
through C# code, by creating a dynamic table using TableHeaderCell and
TableHeaderRow.
The data is binded to the table by using a DataSet and Data Reader.
The responses on the forum made me think that it would be easier to sort the
data in the table (when clicking on the header column), by adding a hidden
field in the aspx form and getting the clicked sorting column (expression) in
C#, create a sorting clause.
Probably it is a easy question, but I am new to designing with C# and .NET
framework.
Does anybody know what is the .NETmethod or property of the
DataSET,SQLAdapter or Reader which has to be used to get the value from the
hidden field to sort ASC or DESC ?
I know that first I have to create the value:
string sort = this.hiddenfield.value
if (sort=="column_clicked_value")
{
.........??????????
//How to rebind and sort ASC or DESC?
}
Can anybody help me please?
Thank you.
Dan
Dan,
Ideally, I would continue to study the language and learn myself
without asking others.
Seems to me that you need to write a SQL language query that will do
ASC or DESC, and incorporate this query into your .NET code. Though
it's true that the SQL query will be handled by the back end rather
than the front end, it's also true SQL is more stable and likely
somebody years from now can read your code without a problem, unlike
the road you're traveling now.
If you don't like that suggestion, and insist on working with the
front end, then why don't you quit trying to figure out if
DataSET,SQLAdapter or Reader has a sorting function (and I assume
you've looked at the help topics on what members they have), and
instead just use a standard C# generic collection class in your own
class to sort, like a List or Array and use Quicksort/ Sort on it?
BTW the SQL adapter and the like are complex pieces of code that you
should only use to do the data binding and back and forth that they
provide, and you should not overload them to do sorting stuff, IMO.
Also learning C# on the front end for dB design is frustrating because
there appears to me (and I'm not an expert) lots of undocumented
casting using the "As" operator, and the like. Or so it seems (in my
mind's eye).
Hope this was "helpful".
Ray