title: Updating sort order using Jquery sortable and gridview
body: <p>I have a gridview that I am populating with SQL data.  I am able to sort the records using jQuery soratble.  When I click on the btnUpdadateSortOrder button and run the my script, I receive no errors however the sort order doesn't update.  after I drag and drop to create a new order my array seems to keep the old order.  what should I be using to set my vid_id()????</p>
  
  <pre><code>      &lt;asp:GridView ID="gvVideos" CssClass="gvVideosClass" runat="server" 
          AutoGenerateColumns="False" DataKeyNames="CustomerId"
          OnRowDataBound="OnRowDataBound" OnRowEditing="OnRowEditing" OnRowCancelingEdit="OnRowCancelingEdit"
          OnRowUpdating="OnRowUpdating" OnRowDeleting="OnRowDeleting" EmptyDataText="No records has been added."&gt;
          &lt;Columns&gt;
               &lt;asp:TemplateField HeaderText="Customer"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="customerId" runat="server" Text='&lt;%# Bind("customerId")%&gt;'&gt;&lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="lblcustomerID" runat="server" Text='&lt;%# Bind("customerId")%&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;ItemStyle Width="160px" /&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Fid" ItemStyle-Width="50"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="lblvidID" runat="server" Text='&lt;%# Bind("fID")%&gt;' /&gt;
                      &lt;input type="hidden" name="vidId" value='&lt;%# Eval("fId")%&gt;' /&gt;
                  &lt;/ItemTemplate&gt;
  
  
  
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;
  
  
          &lt;br /&gt;
          &lt;asp:Button ID="btnUpdateSortOrder" runat="server" Text="Update Sort Order"
              OnClick="btnUpdateSortOrder_Click" /&gt;
  </code></pre>
  
  <p>here is my codebehind</p>
  
  <pre><code>  ' stores id_ in array
      Dim vid_id As String() = New String(gvVideos.Rows.Count - 1) {}
      For i As Integer = 0 To gvVideos.Rows.Count - 1
          vid_id(i) = CInt(DirectCast(gvVideos.Rows(i).Cells(1).FindControl("vidId"), Label).Text)
      Next
  
     ' This worked at one point but now doesn't.       
        'Dim id_language As String() = Request.Form.GetValues("fId")
      Dim sortNumber As Integer = 1
      Dim mySort As New vidController
      ' Loop over array, which contains id_ 
      For Each i As String In vid_id
          ' method which which fire update query order save into database
          mySort.updateVidSortOrder(i, sortNumber)
          sortNumber += 1
      Next
      Response.Redirect(Request.RawUrl)
  </code></pre>
  
  <p>working code: </p>
  
  <pre><code>  Dim vid_id As String() = Request.Form.GetValues("vidId")
      Dim sortNumber As Integer = 1
      Dim mySort As New vidController
      ' Loop over array, which contains id 
      For Each i As String In vid_id
          ' method which which fire update query order save into database
          mySort.updateVidSortOrder(i, sortNumber)
          sortNumber += 1
      Next
      Response.Redirect(Request.RawUrl)
  </code></pre>