0

我在linkbutton onClientClick. 但它正在调用一个错误。

return confirm('""Are you sure you want to report on the  & **row.Cells(3).Text** &  vs  & **row.Cells(4).Text** & game, at the  & **row.Cells(5).Text** &  stadium. For  & **row.Cells(2).Text** &  on the  & **row.Cells(1).Text &** " ."'); 

下面是其余的代码。

<asp:gridview id="FixtureGridView" runat="server"
              autogeneratecolumns="False"
              datasourceid="matches"
              height="140px" 
              width="800px" 
              onselectedindexchanged="FixtureGridView_SelectedIndexChanged">
              <columns>
                  <asp:commandfield showselectbutton="True" />
                  <asp:boundfield datafield="date" headertext="date" sortexpression="date" readonly="True" />
                  <asp:boundfield datafield="kick-off time" headertext="kick-off time" sortexpression="kick-off time" />
                  <asp:boundfield datafield="home team" headertext="home team" sortexpression="home team" />
                  <asp:boundfield datafield="away team" headertext="away team" sortexpression="away team" />
                  <asp:boundfield datafield="stadium" headertext="stadium" sortexpression="stadium" />
                  <asp:TemplateField>
                      <ItemTemplate>
                          <asp:LinkButton ID="LinkButton1" Runat="server"
                                          OnClientClick="return confirm('Are you sure you want to report on this game');"
                                          CommandName="Select">
                          Report
                          </asp:LinkButton>
                      </ItemTemplate>
                  </asp:TemplateField>
4

2 回答 2

1

您应该能够使用以下Eval功能构建确认:

<asp:Button OnClientClick="return confirm('<%# String.Format("Delete {0}?", Eval("SomeColumn")) %>');" />
于 2011-11-23T15:20:45.663 回答
0

您可以像这样使用gridview的row_databound事件,您必须将找到的控件转换为相同的控件类型

if (e.Row.RowType == DataControlRowType.DataRow) {
    LinkButton link = (LinkButton)e.Row.FindControl("LinkButton1");
    link.Attributes.Add("onclick", "return confirm('Are you sure you want to report on this game');");
}
于 2011-11-24T02:30:45.753 回答