(ASP.NET) 在网格视图中,如何使选定的行数据显示在确认对话框上?
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够使用
Eval
函数构建确认:You should be able to build the confirmation using the
Eval
function:您可以像这样使用gridview的row_databound事件,您必须将找到的控件转换为相同的控件类型
you can use the row_databound event of the gridview like this, you have to cast the found control to the same control type