C# Gridview行命令在服务器上不启动,但在本地工作
Gridview RowCommand不会在服务器上启动,但当我在本地系统上使用它时,它会工作。但当我发布并发布到服务器时,RowCommand不会启动。你能给我一个解决方案吗?这是我的Grid view代码 Aspx代码:C# Gridview行命令在服务器上不启动,但在本地工作,c#,asp.net,gridview,C#,Asp.net,Gridview,Gridview RowCommand不会在服务器上启动,但当我在本地系统上使用它时,它会工作。但当我发布并发布到服务器时,RowCommand不会启动。你能给我一个解决方案吗?这是我的Grid view代码 Aspx代码: <asp:GridView ID="gvCandiList" runat="server" Style="border: 1px;" RowStyle-BorderColor="#ebf3e4"ViewStateMode="Enabled" RowStyle-B
<asp:GridView ID="gvCandiList" runat="server" Style="border: 1px;" RowStyle-BorderColor="#ebf3e4"ViewStateMode="Enabled" RowStyle-BorderStyle="None" GridLines="Both" PageSize="10" AllowPaging="true" AutoGenerateColumns="false" Width="100%" AlternatingRowStyle-BackColor="" CssClass="grdCandList" RowStyle-CssClass="RowStyle" AlternatingRowStyle-CssClass="AltRowStyle" HeaderStyle-CssClass="grdheaderCandList"
DataKeyNames="UserId" OnPageIndexChanging="gvCandiList_PageIndexChanging" OnRowCommand="gvCandiList_RowCommand"OnRowDataBound="gvCandiList_RowDataBound" AllowSorting="true" OnSorting="gvCandiList_Sorting">
<EmptyDataTemplate>
<div class="shadowbox" style="min-height: 75px;">
<br />
<center>
No Data Found.</center>
</div>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Name" ItemStyle-CssClass="grdcolumncenter" HeaderStyle-CssClass="grdcolumnheadermiddle pad_left5 pad_right5 NameHeaderWidth"
SortExpression="CandiName">
<ItemTemplate>
<h4 style="font-size: 13px; text-align: left; font-weight: normal !important; color: rgb(67, 73, 75);font-family: Calibri;">
<asp:LinkButtonID="lnkCandidateView" runat="server" Style="text-decoration: none;
color: rgb(67, 73, 75);" onmouseover='mouseover(this);' onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>'>
<asp:Label ToolTip='<%# Eval("CandiName")%>' ID="lblGrdCandiName" runat="server"Text='<%# Eval("CandiName")%>'></asp:Label></asp:LinkButton></h4>
<asp:ImageButton ID="ImageButton1" runat="server" Visible="false" ImageUrl="~/Images/edit.png"CommandName="Modi" CommandArgument='<%# Eval("UserId")%>' ToolTip="Edit" />
<asp:ImageButton ID="ImageButton2" runat="server" ToolTip="View" Visible="false"
ImageUrl="~/Images/view.png" CommandName="View" CommandArgument='<%# Eval("UserId")%>' />
<asp:ImageButton ID="ImageButton3" runat="server" ToolTip="Delete" Visible="false" ImageUrl="~/Images/delete.png" CommandName="Del" CommandArgument='<%# Eval("UserId")%>'
OnClientClick="return confirm('Are you sure ?');" />
<div style="float: left;">
<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ImageButton ID="imgbtnNewCmnt" runat="server" Visible="false" CommandName="NewCmnt" CommandArgument='<%# Eval("CandidateId")%>' ToolTip="New Comment" ImageUrl="~/Images/reminder.png" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
元素“按钮”的开始标记和结束标记之间不允许有内容 因此,将您的lnkCandidateView按钮替换为
<asp:Button ID="lnkCandidateView" ToolTip='<%# Eval("CandiName")%>' Text='<%# Eval("CandiName")%>'
runat="server" Style="text-decoration: none; color: rgb(67, 73, 75);" onmouseover='mouseover(this);'
onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>' />
似乎是一个
viewState
问题。一种解决方案是将GridView的EnableViewState
属性设置为true
您已设置了ViewStateMode=“Enabled”
,因此不确定GridView继承的最终设置是什么。可能是母版页的ContentPlaceHolder
已设置了viewstate
关掉。试着打开它。它的链接按钮不是一个按钮。当然是asp:按钮,但是你给这个按钮提供了lnkCandidateView id,所以我只是指示你按照我的回答更换这个按钮
<asp:Button ID="lnkCandidateView" ToolTip='<%# Eval("CandiName")%>' Text='<%# Eval("CandiName")%>'
runat="server" Style="text-decoration: none; color: rgb(67, 73, 75);" onmouseover='mouseover(this);'
onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>' />