GridView RowCommand 根本没有触发图像按钮
GridView RowCommand Not Firing at all for image button
我正在尝试在我的 GridView 中点击图像按钮时触发 rowCommand 事件。
GridView 位于更新面板内。
但是在尝试了所有方法之后:
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;
}
}
请帮忙。
伙计们,问题是 ItemTemplate 中的标签不小心有相同的 ID,所以事件被阻塞了。
谢谢
我正在尝试在我的 GridView 中点击图像按钮时触发 rowCommand 事件。 GridView 位于更新面板内。 但是在尝试了所有方法之后:
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;
}
}
请帮忙。
伙计们,问题是 ItemTemplate 中的标签不小心有相同的 ID,所以事件被阻塞了。
谢谢