(ASP.NET) 在网格视图中,如何使选定的行数据显示在确认对话框上?

发布于 2024-12-18 01:54:27 字数 1895 浏览 2 评论 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>

I tried the following code on a linkbutton onClientClick. But it is calling an error.

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 &** " ."'); 

Below is the rest of the code.

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若相惜即相离 2024-12-25 01:54:27

您应该能够使用 Eval 函数构建确认:

<asp:Button OnClientClick="return confirm('<%# String.Format("Delete {0}?", Eval("SomeColumn")) %>');" />

You should be able to build the confirmation using the Eval function:

<asp:Button OnClientClick="return confirm('<%# String.Format("Delete {0}?", Eval("SomeColumn")) %>');" />
只有影子陪我不离不弃 2024-12-25 01:54:27

您可以像这样使用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');");
}

you can use the row_databound event of the gridview like this, you have to cast the found control to the same control type

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');");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文