在Gridview中取消匹配选定的索引

时间:2016-12-12 14:01:01

标签: c# asp.net gridview

我有一个gridview,这个gridview有一个选择按钮,在标题下面有一行搜索。当我单击选择按钮时,它们会转到右侧。 enter image description here 但是,当我点击此页面的最后一行时,他们不会告诉我该行的详细信息。 gridview'选择'按钮将直立移动一行。像这样enter image description here

什么是错的,我什么都不知道。

 protected void gv_rdk_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = gv_rdk.SelectedRow;

            if (row.RowIndex >= gv_rdk.Rows.Count-2) { return; }

            GridViewRow selectedRow = gv_rdk.Rows[row.RowIndex +1];

            string nond, nost, halst;

            nond = selectedRow.Cells[0].Text;
            Session["nomornd"] = nond;
            nost = selectedRow.Cells[1].Text;
            Session["nomorst"] = nost;
            halst = selectedRow.Cells[2].Text;
            Session["perihalst"] = halst;
            Response.Redirect("rdk_rincian.aspx");
        }

这是gridview代码

 <asp:GridView ID="gv_rdk"
    CssClass="table table-bordered"
    runat="server"
    BorderColor="#1E6BBC"
    BorderStyle="None"
    OnDataBound="OnDataBound"
    BorderWidth="1px"
    CellPadding="3"
    ShowFooter="True"
    AutoGenerateColumns="False"
    AllowPaging="True"
    OnSelectedIndexChanged="gv_rdk_SelectedIndexChanged"
    OnPageIndexChanging="OnPaging" DataSourceID="ds_rdk">
    <RowStyle BackColor="#EFEFEF" />
    <PagerStyle CssClass="gridview" />
    <AlternatingRowStyle BackColor="white" />
    <Columns>
        <asp:BoundField DataField="nond" HeaderText="Nomor ND" SortExpression="nond" />
        <asp:BoundField DataField="nost" HeaderText="Nomor Surat Tugas" SortExpression="nost" />
        <asp:BoundField DataField="halst" HeaderText="Hal Surat Tugas" SortExpression="halst" />
        <asp:CommandField ShowSelectButton="True" ControlStyle-CssClass="btn btn-success" />
    </Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ds_rdk" runat="server" SelectMethod="AmbilData" TypeName="quittance.Kelas.rdkDataAccessLayer"></asp:ObjectDataSource>

搜索文本框的Javascript:

        <script type="text/javascript">
        $(function () {
            $('.tabelst').each(function (i) {
                $(this).quicksearch("[id*=gv_rdk] tr:not(:has(th))", {
                    'testQuery': function (query, txt, row) {
                        return $(row).children(":eq(" + i + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;
                    }
                });
            });
        });
</script>

0 个答案:

没有答案