Iam尝试在我的GridView中单击Image按钮上的rowCommand事件。 GridView位于Update Panel中。 但在尝试了所有方法之后:
EnableViewState,
在IsPostback上绑定网格,
我无法得到确切的理由。
请找到以下代码:
<asp:GridView ID="grdReport" runat="Server" CellPadding="0" Height="50%" HeaderStyle-CssClass="dataHeadStyle"
OnPageIndexChanging="grdReport_PageIndexChanging" CssClass="lblStyle" AutoGenerateColumns="false" ShowHeader="true" ShowFooter="false"
GridLines="Both" Width="100%" AlternatingRowStyle-CssClass="dataAltRowStyle"
RowStyle-CssClass="dataItemsStyle2" DataKeyNames="TRAINING_ID" AllowPaging="true"
PageSize="7" OnRowCommand="grdReport_RowCommand" OnRowDataBound="grdReport_RowDataBound" EnableViewState="true">
<Columns>
<asp:TemplateField HeaderText="Select" ItemStyle-CssClass="dataItemsStyle1">
<ItemStyle HorizontalAlign="Center" Width="7%" />
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:ImageButton ID="ImgSelect" runat="server" CausesValidation="false" ImageUrl="~/Images/edit_icon.gif"
CommandName="select" CommandArgument='<%# Eval("TRAINING_NAME")+","+ Eval("TRAINING_DESCRIPTION")+","+ Eval("TRAINING_DUE_DATE")%> '/>
</ItemTemplate>
<ControlStyle CssClass="ViewHand" />
</asp:TemplateField>
protected void grdReport_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
string TrainingInfo = e.CommandArgument.ToString();
MS_RITBL objBL = new MS_RITBL();
//string Mst_Report_Id = string.Empty;
//string Report_ID = string.Empty;
//string IsReportLocked = string.Empty;
//string lockedBy = string.Empty;
//string due_date = string.Empty;
if (e.CommandName == "select")
{
//lnkReportID.Enabled = false;
string strMst_Report_Id = Convert.ToString(e.CommandArgument);
//Session["MST_REPORT_ID"] = Mst_Report_Id;
//SetToolTip();
}
}
catch (Exception)
{
throw;
}
}
请帮助。
答案 0 :(得分:1)
问题是,ItemTemplate中的标签意外地具有相同的ID,因此事件被阻塞。
由于