Click here to Skip to main content
16,018,664 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I need to implement a gridview from a database table. Then it should facilitate to reorder the rows of the gridview and then hit a save button and the records gets saved in another similar table with the chosen order. Gridview can have hardly 10 rows.

e.g.

format can be

t1 descr1 upbtn downbtn
t2 descr2 upbtn downbtn
t3 descr3 upbtn downbtn
.
.
.


My question is how should I reorder the rows of the gridview at the page level before saving. I was thinking of creating a viewstate variable in which to store the dataset which is bound to the gridview and have up and down button for each row in a column. As user clicks one of these button the viewstate variable is updated and bind the gridview i to that viewstate variable to depict the current order. For saving use viewstate dataset.

Do you guys have another suggestion? Do you think having up and down button in each row make sense or there should be a textbox where user enters an integer but then user can make mistake of having duplicate numbers etc.

Thanks,

Vijay
Posted

I would not use a gridview, I'd write my own control to have more control over the data and the rendering. I'd then use arrows and use javascript to swap on the client end, probably using a hidden variable to store a list that told me the new order on postback.
 
Share this answer
 
U can always sort a datatable depending on a column name ..
Sort it and save it back ! :)

U can also sort a gridview based on a column name...
 
Share this answer
 
v2
Comments
htm11 8-Nov-12 16:59pm    
This is not an answer and does not address the issue of reordering. Sorting is not reordering. That is to say record 5 may need to be placed before record 3. There are no fields to sort this type of reordering. This about a list of addresses for a delivery person. Perhaps the sequence needs to change.
Sorry for late reply ..
u can sort the datatabe by creating a dataview out of it -

Exp;

DataView dataView = new DataView(dTable);

dataView.Sort = " AutoID DESC, Name DESC";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900