.NET GridView:自定义分页文本

时间:2016-05-30 07:29:52

标签: c# asp.net gridview

编辑:新代码

  <asp:Panel ID="pnl_display_commentaire" runat="server" GroupingText="Commentaires" >


                 <asp:LinkButton ID="btnmakecomment" class="linkhover" Font-Size="11px" runat="server"> Comments </asp:LinkButton>
              <asp:Panel ID="pnlMComment" CssClass="" runat="server" >
                          <div class="commentbox">
                                       <asp:TextBox ID="MakeComments" CssClass="unwatermarkedcomment" runat="server" Width="90%" TextMode="MultiLine"></asp:TextBox>
                                       <asp:Button ID="btnPost" CssClass="submitButton" Text="Commenter" runat="server" OnClick="btnComment_Click" CommandName="Comment"  CausesValidation="false" UseSubmitBehavior="False"/>
                                    ajaxToolKit:TextBoxWatermarkExtender ID="TextBoxScrapWme" runat="server" TargetControlID="MakeComments"  WatermarkText="Ecrire un commentaire" WatermarkCssClass="watermarked" />
                            </div>
             </asp:Panel>

            <ajaxToolKit:CollapsiblePanelExtender ID="cpe1" runat="Server" TargetControlID="pnlMComment"  Collapsed="true" CollapsedText="Ajouter votre commentaire" ExpandedText="" TextLabelID="btnmakecomment"     ExpandControlID="btnmakecomment" CollapseControlID="btnmakecomment" SuppressPostBack="true" />
             <script src="https://code.jquery.com/jquery-1.12.2.min.js"></script>
             <script type="text/javascript">
                function Move() {
                     var shouldMove = true;

                     setInterval(function () {
                         var previous = $("a:contains('Previous')");

                         if (previous.html() != undefined && shouldMove) {
                             var grid = $("#CommentGridView");
                             $(previous).insertBefore($(grid));
                             shouldMove = false

                         }
                     }, 100);

                     $(document).on('click', "a:contains('Next')", function () {
                         shouldMove = true;

                     });

                     $(document).on('click', "a:contains('Previous')", function () {
                         shouldMove = true;
                     });

                 }
</script>

             <asp:UpdatePanel ID="update_panel_comments" runat="server">
                 <ContentTemplate>
                                <asp:GridView ID="CommentGridView"
            AutoGenerateColumns="true"
            EnableSortingAndPagingCallbacks="true"
            EmptyDataText="0 commentaire"
            runat="server"
            ShowHeader="false"
            ShowFooter="true"
            Width="90%"
            AllowPaging="True"
            PageSize="3"
            GridLines="None"
            OnPageIndexChanging="CommentGridView_PageIndexChanging">
            <PagerSettings NextPageText="Next" PreviousPageText="Previous" Mode="NextPrevious" />
        </asp:GridView>
                     </ContentTemplate>
                  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnPost" EventName="Click" />
</Triggers>

         

我试图在我的GridView和数据底部显示下一页链接,并在gridview顶部显示上一个链接(如果需要显示)。

我怎样才能实现这个目标?

编辑: 我用console.log()测试了JS,它输入正确但什么也没做......

1 个答案:

答案 0 :(得分:1)

很难修改ASP.NET Web表单自动为您生成的代码,这就是为什么许多开发人员更喜欢ASP.NET MVC的原因。不过,这里有一个使用非常少的jQuery将&#34; Previous&#34; 链接移动到getData : function (url, htmlType, callback) { ... }.bind(this), 顶部的示例:

GridView

<强>输出:

Changing the location of paging buttons in asp.net gridview