【发布时间】:2021-06-03 13:59:44
【问题描述】:
<asp:GridView class="table table-striped table-bordered " ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="dish_id" DataSourceID="SqlDataSource1" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="dish_id" HeaderText="ID" ReadOnly="True" SortExpression="dish_id" />
<asp:TemplateField>
<ItemTemplate>
<div class="container-fluid">
<div class="row">
<div class="col-lg-8">
<div class="row">
<div class="col-12">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" Text='<%# Eval("dish_name") %>'></asp:Label>
</div>
</div>
<div class="row">
<div class="col-12">
Category-<asp:Label ID="Label2" Font-Bold="True" runat="server" Text='<%# Eval("cat_name") %>'></asp:Label>
| Cuisine-
<asp:Label ID="Label3" Font-Bold="True" runat="server" Text='<%# Eval("cuisine") %>'></asp:Label>
| Price-
<asp:Label ID="Label4" Font-Bold="True" runat="server" Text='<%# Eval("price") %>'></asp:Label>
</div>
</div>
<div class="row">
<div class="col-12">
Description-
<asp:Label Font-Bold="True" ID="Label5" runat="server" Text='<%# Eval("dish_description") %>'></asp:Label>
</div>
</div>
</div>
<div class="col-lg-2">
<asp:Image class="img-fluid" ID="Image1" runat="server" ImageUrl='<%# Eval("dish_img_link") %>' />
</div>
<div class="col-lg-2">
<asp:Button ID="Button1" class="btn btn-outline-info btn-block btn-sm" runat="server" Text="Add to Cart" OnClick="Button1_Click" />
</div>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我在每一行前面都有这个 GridView & 按钮(添加到购物车),我想获取单击其按钮的特定行的 ID。我观看了一些使用复选框更改事件的教程,但我想使用 button_click 事件获取 id。有可能吗?
【问题讨论】:
标签: c# asp.net .net visual-studio e-commerce