473,473 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sorting a table using hidden field

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
Jul 16 '08 #1
6 4044
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
Jul 16 '08 #2
You need to make a DataView from the DataTable.
E.g
DataTable table;
DataView view = table.DefaultView;
view.Sort = "ColumnToSortBy ASC";

Then use the DataView as the binding source.

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Dan" wrote:
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
Jul 16 '08 #3
This post doesnt seem very helpful apart from the suggestion of sorting a
list held in an array. People often post here when they have tried everything
they can think of to get around a problem and there are a lot of people here
who are happy to help. This forum is supposed to be a .NET community and that
means people are here to help each other learn more about .NET.
I understand that it is obviously preferable for people to figure out the
issues they have on their own as it will help them in the future if they dont
have access to a resource like this, but there have been times in my career
where I have wanted to ask a question in a place like this to make sure I am
not re-inventing the wheel.
It would make this forum a friendlier place if you could limit your posts to
simply trying to help people rather than making them feel bad for asking
their questions here. Try reading the responses that the MVP's give in these
forums and notice they are normally in a friendly and supportive tone.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"raylopez99" wrote:
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
Jul 16 '08 #4
On Jul 16, 6:53*am, Ciaran O''Donnell
<CiaranODonn...@discussions.microsoft.comwrote:
Try reading the responses that the MVP's give in these
forums and notice they are normally in a friendly and supportive tone.
Yeah, like Peter Dunohoe? Or whatever his name is. He claims to be
an MVP. And my advice BTW was good--perhaps not as good as yours, but
still good.

Thanks, for making me feel bad.

RL
Jul 16 '08 #5
Peter Duniho isnt an MVP and doesnt put MVP on the end of him name and I
havent seem him claim to be an MVP.
Your advice was good and I did say that in my post. My point was that making
the OP feel bad for asking here rather than finding it out himself was not
necessary.
I had no intention of making you feel bad, I just wanted to point out my
opinion on these forums and the people that seek help here.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"raylopez99" wrote:
On Jul 16, 6:53 am, Ciaran O''Donnell
<CiaranODonn...@discussions.microsoft.comwrote:
Try reading the responses that the MVP's give in these
forums and notice they are normally in a friendly and supportive tone.

Yeah, like Peter Dunohoe? Or whatever his name is. He claims to be
an MVP. And my advice BTW was good--perhaps not as good as yours, but
still good.

Thanks, for making me feel bad.

RL
Jul 17 '08 #6
On Jul 17, 1:29*am, Ciaran O''Donnell
<CiaranODonn...@discussions.microsoft.comwrote:
Peter Duniho isnt an MVP and doesnt put MVP on the end of him name and I
havent seem him claim to be an MVP.
Yes he is. Or so he says, earlier this week in a thread:
[...]
Speaking of poor programmer, I see Ben Voight has the prestigious [C++
MVP] abbreviation next to his name--funny, I don't see that next to
your name.
[Peter Duniho] That's true, you don't. While I am in fact a recipient
of the C# MVP
award, I choose not to include that in my posting credentials. So
what?
--
Your advice was good and I did say that in my post. My point was that making
the OP feel bad for asking here rather than finding it out himself was not
necessary.
I had no intention of making you feel bad, I just wanted to point out my
opinion on these forums and the people that seek help here.
Don't worry about it. I'm only being a polarizing author, sometimes
pejoratively called a troll, which gets more replies (wheel,
squeeking, etc).

And thanks for your input. I code for fun but appreciate professionals
or near professionals like yourself (and Peter, and Jon, and Ben,
etc).

RL
Jul 17 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
1
by: james00_c | last post by:
Greetings- I need to pass multiple email addresses to a "sendto" hidden field in a form. I need to do that because "CC" and "BCC" are not an option. One address webmaster@xyz.com would be...
2
by: Rodusa | last post by:
I have a hidden field inside one datagrid which I can't get to make it keep its state after a postback event. Look field: <input type="hidden" id="TxtHiddenItem_id" name="TxtHiddenItem_id"...
4
by: Magnus Blomberg | last post by:
Hello! I have a problem when using a hidden field to send a value to the server. Below you can see my code in simplyfied versions. What I'm trying to do is: 1. The user browses for a picture...
3
by: Metplant | last post by:
I have almost no experience in ACCESS so am trying to get the system functioning with minimal operator input. Currently I have managed to modify a database generated by a SCADA system using a...
4
by: ConfusedMay | last post by:
Hi, I have a form with a text box called notes(using memo field type, since it'll be more than 255 field size), so users can enter whatever notes or complaints for a specific products. The problem...
3
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
1
by: sbettadpur | last post by:
Hi help me anybody, here is my requirement i have totally 4 web pages, if i want to send data from 1st page then i need to get at 4th page with out using hidden field concept in text fields from...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.