点击我的gridview中的按钮(btn_goToPoint)不会被拦截。有一个负载,但重定向不起作用。当我在后面的代码(grd_points_rowCommand)中放置断点时,代码不会在那里执行。在我点击按钮之前,我遇到了一个错误,我用“EnableEventValidation =”false“”解决了这个问题。 我没有发现问题,因为我在我的应用程序的其他页面上使用完全相同的东西并且它有效。
<asp:GridView ID="grd_points" runat="server" CssClass="mydatagrid" PagerStyle-CssClass="pager"
HeaderStyle-CssClass="header" RowStyle-CssClass="rows"
AutoGenerateColumns="False" DataKeyNames="POI_id"
DataSourceID="ERP_pointsByQuestion"
OnRowDataBound = "grd_points_RowDataBound"
OnRowCommand="grd_points_RowCommand">
<Columns>
<asp:BoundField DataField="POI_id" HeaderText="Num." ReadOnly="True"
SortExpression="POI_id" />
<asp:BoundField DataField="POI_situation" HeaderText="Situation"
SortExpression="POI_situation" />
<asp:BoundField DataField="c_evalPoint" HeaderText="Eval."
SortExpression="c_evalPoint" />
<asp:BoundField DataField="EVA_couleur" HeaderText="Couleur"
SortExpression="EVA_couleur" />
<asp:BoundField DataField="USE_cdsid" HeaderText="Responsable"
SortExpression="USE_cdsid" />
<asp:BoundField DataField="POI_dateRevision" HeaderText="Date Révision"
SortExpression="POI_dateRevision" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button class="btn btn-primary" ID="btn_goToPoint" runat="server"
CommandName="goToPoint"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
Text="►" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
后面的代码:
protected void grd_points_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "goToPoint")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = grd_points.Rows[index];
string value = row.Cells[0].Text;
Response.Redirect("gest_point.aspx?point=" + value);
}
}