Last post Oct 10, 2007 12:08 PM by jdbene
Oct 07, 2007 11:41 PM|jdbene|LINK
I have a table that is displayed in a GridView in which I would like to allow the user to change the order. The way I have temporarily set it up is by having a Rank field in my database by which the GridView is sorted. The user then has to tell the page
what he wants the rank to be when adding a record. The field allows duplicate entries right now and the user has to specify a value for Rank when creating records. I would like to implement an up / down arrow on the edit template of each record and have created
a column with two "dumb" image buttons that I would like to activate for this purpose. I would like to make the Rank field transparent to the user.
How can I make the rank field automatically index by one to eliminate the need for the user to enter a rank when adding a record?
What kind of logic would I put behind the image buttons to allow the user to bump a record up or down by one?
I've made the imagebutton invisible for the top record by setting visible to false if the rowIndex=1. How can I get the last row of the gridview so that I can do the same for the last record shown to eliminate the possiblity to bump the bottom record down?
I'm a newbie, so I really appreciate the help. (I'm using C# and asp.net for the first time)
Oct 08, 2007 09:58 AMfirstname.lastname@example.org|LINK
it may be
Private Sub dbGrid_surgeons_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dbGrid_surgeons.SortCommand
Dim sSort As String
sSort = "[" + e.SortExpression.ToString + "]"
Dim col, _col As DataGridColumn
For Each col In dbGrid_surgeons.Columns
col.HeaderText = col.HeaderText.Replace("<IMG src=""Images/up.gif"" border=0/>", "")
col.HeaderText = col.HeaderText.Replace("<IMG src=""Images/down.gif"" border=0/>", "")
col.HeaderStyle.Wrap = False
If "[" + col.SortExpression + "]" = sSort Then _col = col
If Session("dbGrid_surgeons_Sort") = sSort + " ASC" Then
Session("dbGrid_surgeons_Sort") = sSort + " DESC"
If Not _col Is Nothing Then _col.HeaderText = _col.HeaderText + " <IMG src=""Images/down.gif"" border=0/>"
Session("dbGrid_surgeons_Sort") = sSort + " ASC"
If Not _col Is Nothing Then _col.HeaderText = _col.HeaderText + " <IMG src=""Images/up.gif"" border=0/>"
In binddata procedure u populate the data
Please remember to click "Mark as Answer" on this post if it helped you.
Oct 08, 2007 06:33 PM|jdbene|LINK
Do you happen to know how this would look in C#? I'm not at all familiar with VB
Oct 09, 2007 03:16 AMemail@example.com|LINK
Hi i m providing a link . Through this site u can convert vb.net code to c#
Oct 10, 2007 12:08 PM|jdbene|LINK
Is my GridView supposed to have a SortCommand event? I don't understand how this is called method when my up or down button is clicked. Do I just reference it from my ImageButton_Click event?
Also, just to make sure I explained correctly, I'm posting a picture of the GridView and what I want the buttons to do:
So in this case, I want to swap "Our Organization" and "About Us" with the up arrow or "Our Organization" and "Services" with the down arrow.