473,770 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shuffling rows in a GridView

One of the gridviews i'm using now apparently needs to have the added
functionality of re-arranging the order of the records it's
representing. These records have a priority field which the dataset
gets sorted on and I thought the quickest way to do this would be to
add "move up", "move down" buttons next to the grid which would shuffle
the rows up and down by swapping their priority field values and
updating.

At least that seemed to be the quickest way before I spent a day
pouring through documentation trying to find a way to get at the
dataset of the gridview with no success whatsoever. Thing's locked up
tighter than a duck's. Is there any way on God's green earth to access
the data of a gridview? Or is there a better way to do this, you see it
all the time with listboxes I'd hoped I could get the gridview to play
along...

Sep 1 '06 #1
3 6338
I don't believe this is built in simply because row order is not usually an
overriding concern. But's it's really easy to do. Just re-order the
datasource, dataview, or dataset and rebind.

On second thought, if you need flexibility in row ordering, you should be
using a listbox and not a gridview.

--
_______________ _________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"justin" <ju************ @gmail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
One of the gridviews i'm using now apparently needs to have the added
functionality of re-arranging the order of the records it's
representing. These records have a priority field which the dataset
gets sorted on and I thought the quickest way to do this would be to
add "move up", "move down" buttons next to the grid which would shuffle
the rows up and down by swapping their priority field values and
updating.

At least that seemed to be the quickest way before I spent a day
pouring through documentation trying to find a way to get at the
dataset of the gridview with no success whatsoever. Thing's locked up
tighter than a duck's. Is there any way on God's green earth to access
the data of a gridview? Or is there a better way to do this, you see it
all the time with listboxes I'd hoped I could get the gridview to play
along...

Sep 3 '06 #2
Thanks for the reply Alvin,
Yes a listbox would be a far more clever solution but the existing page
uses the gridview's edit functionality so I can't really change it to a
listbox. And you're right, you just have to re-order the dataset. I
just can't find any way to prise that dataset out of the gridview, or
the objectdatasourc e that i'm using for it. There doesn't seem to be
any way to get to it.

Alvin Bruney [MVP] wrote:
I don't believe this is built in simply because row order is not usually an
overriding concern. But's it's really easy to do. Just re-order the
datasource, dataview, or dataset and rebind.

On second thought, if you need flexibility in row ordering, you should be
using a listbox and not a gridview.

--
_______________ _________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"justin" <ju************ @gmail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
One of the gridviews i'm using now apparently needs to have the added
functionality of re-arranging the order of the records it's
representing. These records have a priority field which the dataset
gets sorted on and I thought the quickest way to do this would be to
add "move up", "move down" buttons next to the grid which would shuffle
the rows up and down by swapping their priority field values and
updating.

At least that seemed to be the quickest way before I spent a day
pouring through documentation trying to find a way to get at the
dataset of the gridview with no success whatsoever. Thing's locked up
tighter than a duck's. Is there any way on God's green earth to access
the data of a gridview? Or is there a better way to do this, you see it
all the time with listboxes I'd hoped I could get the gridview to play
along...
Sep 5 '06 #3
I think you can get more specialized help for this in the www.asp.net forum.

--
_______________ _________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"justin" <ju************ @gmail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Thanks for the reply Alvin,
Yes a listbox would be a far more clever solution but the existing page
uses the gridview's edit functionality so I can't really change it to a
listbox. And you're right, you just have to re-order the dataset. I
just can't find any way to prise that dataset out of the gridview, or
the objectdatasourc e that i'm using for it. There doesn't seem to be
any way to get to it.

Alvin Bruney [MVP] wrote:
>I don't believe this is built in simply because row order is not usually
an
overriding concern. But's it's really easy to do. Just re-order the
datasource, dataview, or dataset and rebind.

On second thought, if you need flexibility in row ordering, you should be
using a listbox and not a gridview.

--
______________ __________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"justin" <ju************ @gmail.comwrote in message
news:11******* *************** @i3g2000cwc.goo glegroups.com.. .
One of the gridviews i'm using now apparently needs to have the added
functionality of re-arranging the order of the records it's
representing. These records have a priority field which the dataset
gets sorted on and I thought the quickest way to do this would be to
add "move up", "move down" buttons next to the grid which would shuffle
the rows up and down by swapping their priority field values and
updating.

At least that seemed to be the quickest way before I spent a day
pouring through documentation trying to find a way to get at the
dataset of the gridview with no success whatsoever. Thing's locked up
tighter than a duck's. Is there any way on God's green earth to access
the data of a gridview? Or is there a better way to do this, you see it
all the time with listboxes I'd hoped I could get the gridview to play
along...

Sep 14 '06 #4

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

Similar topics

2
2762
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
9
15775
by: =?Utf-8?B?c3Jpbml2YXM=?= | last post by:
Hi All, Can anybody please help me, how to access all rows in a grid view if the paging is enabled? If gridview contains 100 rows and pagecount=10, then in the gridview.rows collection, i'm getting only those 10 rows which are displayed on the screen. But i want to access all the 100 rows in the code. Thanks in advance
2
2116
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent back the proper number of rows. The only thing different I am doing is to display the number of rows returned in the footer of the gridview. The Bindgrid is as follows: Sub BindGrid() Session("reportlevel") = Session("availabilityrptlevel")
0
4824
by: mike0870 | last post by:
Hi, I've been at this one for hours and cannot not find any posts of anyone having the same problem. Ther scenario is, I need to fill a drop down box with a value in the grid row to pass to the select statement whcih returns the rows to the drop down. Its the problem is happening in the ObjectDataSource_Selecting Event of the dropdown control when the Edit command is clicked for a grid row. I'm using the syntax , GridView.rows.FindControl...
0
1969
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" Height="237px" Style="z-index: 100; left: 155px; position: absolute; top: 132px" Width="688px" BackColor="White" BorderColor="#CCCCCC"...
1
7312
by: tucson | last post by:
I have a gridview that has a blank row with 2 input fields: file to upload, and a description of the file. They click Add and a new row is added, Remove and the row is removed. The problem is: When a new row is added, I loop through the existing gridview rows, store the data in a dataset, and rebind. In debug mode, I see the values I entered but when I rebind, it's not displayed in the gridview. Here's the code aspx code: ...
2
5339
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like what hotmail web UI is doing now (having the option of selecting multiple rows (using the checkbox provided) and perform a set of operations on them)
1
1846
by: COHENMARVIN | last post by:
I have a gridview and I need to know the number of rows in it. I find the Page_load and the Gridview_Load events are too early to find out the number of rows. I can use the Gridview_databound event to check for the number of rows. But the problem is that the user can update a field on my form, which reduces the number of rows in the gridview, because the gridview SELECT statement no longer finds the records when their flag has been set...
0
1681
by: Andy B | last post by:
I need to take an existing GridView that connects to a database and gets rows from a table and force it to show x rows in the insert mode. This is what should happen: 1. There is a TextBox in the GridView header where I type the number of rows I want to show in insert mode. Say I type 12. 2. When I click Add, the GridView changes to insert mode showing the 12 rows ready to be filled in. I would use a custom template for insert mode. 3....
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7420
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3974
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 we have to send another system
2
3578
muto222
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.