1
我在內部有DataGrid
。在DataGrid
我有一個Button
「btnTest」。如何從ItemCommand
中確定DataGrid
哪個(Repeater Index)DataGrid
。從Repeater中的ItemCommand識別DataGrid
ASPX:
<asp:Repeater ID="ProdList" OnItemDataBound="ProdList_ItemDataBound" OnItemCommand="ProdList_ItemCommand" runat="server">
<ItemTemplate>
<div style="padding: 5px;">
<asp:DataGrid ID="dtg" OnItemDataBound="dtg_ItemDataBound" OnItemCommand="dtg_ItemCommand" runat="server" AutoGenerateColumns="False" DataSource='<%# DataBinder.Eval(Container.DataItem, "ProductItems") %>'>
<Columns>
<asp:BoundColumn HeaderText="ProdName" DataField="ProdName"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button ID="btnTest" runat="server" CommandName="Test" Text="Test" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<asp:TextBox ID="txtSearch" runat="server" style="width:250px;" CssClass="txtSearch" autocomplete="off"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btnSearch" onclick="btnSearch_Click" />
<asp:Button ID="btnCheckAvailability" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProdId") %>' CssClass="button" CommandName="CheckAvailability" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ProdId") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
ASPX.CS:
protected void ProdList_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
}
}
protected void ProdList_ItemCommand(Object Sender, RepeaterCommandEventArgs e)
{
}
protected void dtg_ItemDataBound(object sender, DataGridItemEventArgs e)
{
}
protected void dtg_ItemCommand(object source, DataGridCommandEventArgs e)
{
// I want to identify DataGrid here
}
請幫助我。
謝謝,它的工作有很多的信息。 – KK5687445