[英].NET GridView : Custom paging text
編輯:新代碼
<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,它輸入正確但什么都不做......
修改 ASP.NET Web 表單自動為您生成的代碼非常困難,這就是為什么許多開發人員更喜歡 ASP.NET MVC。 不過,這里有一個示例,它使用很少的 jQuery 將“上一個”鏈接移動到GridView
的頂部:
<head runat="server">
<title></title>
<script src="https://code.jquery.com/jquery-1.12.2.min.js"></script>
<script>
$(function () {
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>
</head>
<body>
<form id="form1" runat="server">
<div>
<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>
</div>
</form>
</body>
輸出:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.