0
<asp:Repeater ID="RptSCart" runat="server" OnItemCommand="RptSCart_ItemCommand" Visible="false">
    <HeaderTemplate>
        <div class="row text-center align-items-center" style="background-color: pink; height: 70px; color: black">
            <div class="col-md-2"></div>
            <div class="col-md-2">
                <p>Product</p>
            </div>
            <div class="col-md-2">
                <p>Price</p>
            </div>
            <div class="col-md-2">
                <p>Stitch Cost</p>
            </div>
            <div class="col-md-1">
                <p>Quantity</p>
            </div>
            <div class="col-md-2">
                <p>Total</p>
            </div>
            <div class="col-md-1"></div>
        </div>
        <br />
    </HeaderTemplate>
    <ItemTemplate>
        <div class="row text-center align-items-center">
            <div class="col-md-2 ">
                <asp:Image ID="PImage" runat="server" ImageUrl='<%#Bind("Pic")%>' CssClass="img image-prod" Width="100" Height="150" />
            </div>
            <div class="col-md-2">
                <asp:Label ID="LabelPName" runat="server" CssClass="product-name" Text='<%#Bind("PName")%>' ForeColor="Black"></asp:Label>
            </div>
            <div class="col-md-2">
                <asp:Label ID="LabelPPrice" runat="server" CssClass="price" Text='<%#Bind("SPrice") %>' ForeColor="Black"></asp:Label>
            </div>
            <div class="col-md-2">
                <asp:Label ID="lblSPrice" runat="server" CssClass="price" Text='<%#Bind("STPrice") %>' ForeColor="Black"></asp:Label>
            </div>
            <div class="col-md-1">
                <asp:Label ID="Label1" runat="server" CssClass="price" Text="1" ForeColor="Black"></asp:Label>
            </div>
            <div class="col-md-2">
                <asp:Label ID="lblTotal" CssClass="total" runat="server" Text='<%#Bind("Amount") %>' ForeColor="Black"></asp:Label>
            </div>
            <div class="col-md-1">
                <asp:LinkButton ID="lnkRemove" runat="server" CssClass="product-remove" CommandName="Delete"><span class="ion-ios-close-circle"></span></asp:LinkButton>
            </div>
        </div>
        <h1>
            <hr />
        </h1>
    </ItemTemplate>
</asp:Repeater>


DataTable dt1 = (DataTable)Session["Stitch_Cart"];
RptSCart.DataSource = dt1;
RptSCart.DataBind();
RptSCart.Visible = true;

Here is my repeater in which i bind data (products added in cart by customer) from data table. On click of remove button i want to delete row from data table using data table row index instead of repeater index.If quantity of product(xyz) is 2 i am creating two rows in cart and data table (it is according to my requirement). If user wants to remove one, the other one should not be deleted.

Selim Yildiz
  • 4,224
  • 6
  • 14
  • 25
Urwah
  • 31
  • 6
  • ............dt1.Rows[var].Delete();......i tried this container index method. it does not delete 2nd rows and gives error. instead when i delete 1st row it delete 2nd as well(both rows contain same product) – Urwah May 04 '20 at 17:32
  • 1
    Row index is a very unreliable way of identifying records, especially between two different sets. Do you have a way of uniquely identifying a row, such as a record ID that's common to both sets and unique to each row? If so, use that. If not, you should create one. Even if just a temporary GUID to track the records while the user is interacting before committing to some backing system (which definitely *should* have unique identifiers). – David May 04 '20 at 17:34
  • Both rows contain same info except that each row is associated with unique row of another data table. I'll try to work on creating unique index. – Urwah May 04 '20 at 17:38

0 Answers0