473,471 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sotring in dataView

I have gridView, which allows sorting and sqlDataSource, which fill in the
data into gridView.
When user clicks one button, I would like to walk through the records in
grid view(which could be sorted):

String content="";
DataSourceSelectArguments arg=new DataSourceSelectArguments();

arg.SortExpression = grdView.SortExpression;
DataView dv = (DataView)SqlDataSource.Select(arg);

foreach (DataRow dr in dv.Table.Rows)
{
content += "<tr><td>"+dr[1].ToString()+"</tD></tr>";
}

It works only that my result(content) is not sorted like gridView. Why? Have
I missed something?

regards,
Simon
Jul 18 '06 #1
1 1034
If you sort the DataView, and you want to iterate the results in sorted
order, you'd iterate the dataView, not the DataTable (DataTable's Rows are
always in load order)

Your code should be:

//...
DataView dv = (DataView)SqlDataSource.Select(arg);

//Iterate the DataView
foreach (DataRowView dr in dv)
{
content += "<tr><td>"+dr[1].ToString()+"</tD></tr>";
}
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"simonZ" <si*********@studio-moderna.comwrote in message
news:O0*************@TK2MSFTNGP04.phx.gbl...
>I have gridView, which allows sorting and sqlDataSource, which fill in the
data into gridView.
When user clicks one button, I would like to walk through the records in
grid view(which could be sorted):

String content="";
DataSourceSelectArguments arg=new DataSourceSelectArguments();

arg.SortExpression = grdView.SortExpression;
DataView dv = (DataView)SqlDataSource.Select(arg);

foreach (DataRow dr in dv.Table.Rows)
{
content += "<tr><td>"+dr[1].ToString()+"</tD></tr>";
}

It works only that my result(content) is not sorted like gridView. Why?
Have I missed something?

regards,
Simon


Jul 18 '06 #2

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

Similar topics

0
by: RPI_alum | last post by:
I've been experiencing some frustrating behavior that I believe may be a MS bug in the Framework. Has anyone else experienced this, know a better way to resolve it, or if it is an actual MS bug ...
9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
13
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is...
5
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it...
3
by: astro | last post by:
I have a datagrid that is two levels down from the dataview (i.e. grandchild). I have spent 3 hours trying to get the syntax of determining it's real datasource (i.e. not it's source based on it's...
5
by: enceladus311 | last post by:
I'm trying to find a way to keep from having to fill a DataView after every PostBack to a page. Basically, the design is that I have a DataView that I fill, which I then set as the DataSource to a...
0
by: Pravin Pujari | last post by:
Hi All, I am using .net framework 1.1 and c#. I have one problem regarding dataview. I have one dataview to which sorting may be applied or may not be applied. I have one UI component where I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
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.