使用Jquery sortable和gridview更新排序顺序

时间:2015-10-01 18:38:36

标签: javascript jquery asp.net jquery-ui gridview

我有一个gridview,我正在填充SQL数据。我能够使用jQuery soratble对记录进行排序。当我单击btnUpdadateSortOrder按钮并运行我的脚本时,我没有收到任何错误,但排序顺序没有更新。在我拖放以创建新订单后,我的数组似乎保持旧订单。我该怎么用来设置我的vid_id()????

      <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.">
        <Columns>
             <asp:TemplateField HeaderText="Customer">
                <EditItemTemplate>
                    <asp:TextBox ID="customerId" runat="server" Text='<%# Bind("customerId")%>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblcustomerID" runat="server" Text='<%# Bind("customerId")%>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Width="160px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Fid" ItemStyle-Width="50">
                <ItemTemplate>
                    <asp:Label ID="lblvidID" runat="server" Text='<%# Bind("fID")%>' />
                    <input type="hidden" name="vidId" value='<%# Eval("fId")%>' />
                </ItemTemplate>



            </Columns>
        </asp:GridView>


        <br />
        <asp:Button ID="btnUpdateSortOrder" runat="server" Text="Update Sort Order"
            OnClick="btnUpdateSortOrder_Click" />

这是我的代码隐藏

  ' 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)

工作代码:

  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)

1 个答案:

答案 0 :(得分:0)

将此属性添加到您的网格视图中:AllowSorting =&#34; True&#34;

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.


    let key = "my correct key"

    let parameters = [
        "Authorization" : "api:my correct key",
        "from": "sender email",
        "to": "destination email",
        "subject": "Test",
        "text": "Testing email send"
    ]

    let r = Alamofire.request(.POST, "https://api.mailgun.net/v3/<my sandbox>/messages", parameters:parameters)
        .authenticate(user: "api", password: key)
        .response { (request, response, data, error) in
            print(request)
            print(response)
            print(error)
    }
    print(r)
}