Gridview RowCommand在服务器上没有激活,但是当我在本地系统上使用它时它工作。但是当我发布并发布到服务器RowCommand时没有被解雇..那么你给我一个解决方案...这是我的网格视图代码
Aspx代码:
<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>
ASPX.CS
protected void gvCandiList_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("View"))
{
Session["CandiUserId"] = e.CommandArgument.ToString();
DisplayCandidateDetails();
}
}
答案 0 :(得分:1)
元素&#34; 按钮&#34;
的开始和结束标记之间不允许使用内容请用
替换 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")%>' />
答案 1 :(得分:1)
似乎是viewState
问题。一种解决方案是将GridView的EnableViewState
属性设置为true
。
您已设置ViewStateMode="Enabled"
,因此不确定您的GridView继承的最终设置是什么。可能是主页的ContentPlaceHolder
已viewstate
关掉。尝试打开它。