C# .NET GridView:自定义分页文本
编辑:新代码C# .NET GridView:自定义分页文本,c#,asp.net,gridview,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="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>
评论
ajaxToolKit:TextBoxWatermarkExtender ID=“TextBoxScrapWme”runat=“server”TargetControlID=“MakeComments”WatermarkText=“Ecrire un commentaire”watermarkcsclass=“watermarked”/>
函数Move(){
var shouldMove=true;
setInterval(函数(){
var-previous=$(“a:contains('previous'));
if(previous.html()!=undefined&&shouldMove){
var grid=$(“#CommentGridView”);
$(上一个).insertBefore($(网格));
shouldMove=false
}
}, 100);
$(文档)。在('click')上,“a:contains('Next')”,函数(){
shouldMove=true;
});
$(文档)。在('click')上,“a:contains('Previous')”,函数(){
shouldMove=true;
});
}
我试图在GridView和数据的底部显示下一个页面链接,在GridView的顶部显示上一个链接(如果需要显示的话)
我怎样才能做到这一点
编辑:
我用console.log()测试了JS,它输入正确,但什么也不做…很难修改ASP.NET web表单自动为您生成的代码,这就是为什么许多开发人员更喜欢ASP.NET MVC。尽管如此,下面的示例使用很少的jQuery将“Previous”链接移动到
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>
$(函数(){
var shouldMove=true;
setInterval(函数()
{
var-previous=$(“a:contains('previous'));
if(previous.html()!=undefined&&shouldMove)
{
var grid=$(“#CommentGridView”);
$(上一个).insertBefore($(网格));
shouldMove=false
}
}, 100);
$(文档)。在('click')上,“a:contains('Next')”,函数(){
shouldMove=true;
});
$(文档)。在('click')上,“a:contains('Previous')”,函数(){
shouldMove=true;
});
});
My previous link停留在我的gridview底部:/(它在我的gridview底部显示上一个链接,然后显示下一个链接)(我的gridview在更新面板中)我在事件pageindexChanging中调用了你的函数,但它没有做任何事情。你是否将PreviousPageText=“Précédents”更改为PreviousPageText=“previous”?或将javascript更改为var previous=$(“a:contains('Précédents'));没有,我只是用了你所有的代码!他输入的是你的js函数,但什么都不做。(使用console.log进行测试)我知道,我说过我使用了你的代码并替换了我的。我的纸张设置与“上一页”和“下一页”相同。。但它也不起作用