Friday 15 June 2012

asp.net - Swapping GridView rows Up and Down? -


Hello friends, I hope you can help me on this, I have a grid view and each line is given me one up and down. Button now has a sequence number (1, 2, 3.. ATC) in each record, which I want when I rearrange the rows down or down on UP and according to sequence number I searched for it, But what I found did not work for me, can you point me to some articles or give me an idea to help me solve it.

Thank you very much

try the following:

  & amp; Asp: gridview id = "gv" runat = "server" auto generated column = "wrong" OnRowCommand = "gv_RowCommand" & gt; & Lt; Columns & gt; & Lt; Asp: TemplateField ShowHeader = "False" & gt; & Lt; ItemTemplate & gt; & Lt; ASP: Button ID = "btn-up" runat = "server" reason validity = "wrong" commandname = "top" text = "a" ??? / & Gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; Asp: TemplateField ShowHeader = "False" & gt; & Lt; ItemTemplate & gt; & Lt; ASP: Button ID = "BTN daemon" runat = "server" causation = "wrong" commandname = "bottom" text = "a" ??? / & Gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt;   

The above snippet will create a grid view with two columns, one for the up arrow (Alt + 24) and one for the down arrow (Alt + 25).

Now when we click the related buttons, the code needs to be written to handle up or down commands:

  secure void gvQuestion_RowCommand (object sender, GridViewCommandEventArgs E) {try {// handle up command if (e.CommandName == "up") {// log argument argument for relocation (most likely decreases a sequence sequence value) // Rebind grid} // If the handle down command (e.CommandName = "Down") {// logic to move the line down (most likely pay Increase sort value) / / rebound grid}}   

The list object that displays the grid view requires a sort value (Value) or it will retain value in the database so that it can be retrieved Can be done and updated when the rows are moved up or down.

No comments:

Post a Comment