I am building a website whereby people, before checking out of the shopping cart (and transferring to the payment iframe) can select which items from the shopping cart list to delete. The results from the shopping card are listed in a Repeater control. There is a Button in the Repeater which deletes a record from the database (used LINQ to SQL to do that.)

THe problem is that the ItemCommand event doesn't fire when i click the button. I tried 'response.write(test)' and it still would not work. It is as if the repeater cannot interact with the commands. It does render the results tho.

I would really appreciate if you could help me as I'm approaching a deadline and I've exhausted all the resources on the internet before turning to you guys!

Here's the code:

<asp:Repeater ID="RepeaterKoshnichka" runat="server" OnItemCommand="RepeaterKoshnichka_ItemCommand"
            <td background="images/message-bar.gif">
                <div class="message_head" style="float:left"><cite>Производ: <asp:Label ID="lblProizvod" CssClass="red_tx" Text='<%# Eval("Proizvod") %>' runat="server"></asp:Label> / Тип на Претплата: <asp:Label ID="lblPretplata" runat="server" Text='<%# Eval("Tip") %>' CssClass="red_tx"></asp:Label></cite></div>
                <div class="message_head" style="float:right"><cite>Цена: <asp:Label ID="lblCena" CssClass="red_tx" Text='<%# Eval("Cena") %>' runat="server"></asp:Label>&nbsp;
                    <asp:Button ID="Button2" CssClass="main_tx" CommandName="Delete" CommandArgument='<%# Eval("NDetID") %>' runat="server"
                        Text="Отстрани" /></cite>

protected void RepeaterKoshnichka_ItemCommand(object source, RepeaterCommandEventArgs e)
    if (e.CommandName == "Delete")
        if (Request.Form[e.CommandArgument.ToString()] != null)
            if (Page.User.Identity.IsAuthenticated)
                var nar = new DataClasses1DataContext();
                Guid detnar = new Guid(e.CommandArgument.ToString());
                var query = from c in nar.Naracka_Dets
                    where c.NDetID == detnar
                    select c;

                foreach (var c in query)

                lblSuma.Text = ((Button)e.CommandSource).ToString();

Your help is greatly appreciated!

<asp:Repeater ID="Repeater1" runat="server"

and for to understand exact about repeater control see here

The Repeater control is used to display a repeated list of items that are bound to the control.

The Repeater control allows you to create templates to define the layout of its content. The templates are:

· ItemTemplate - Use this template for elements that are rendered once per row of data.

· AlternatingItemTemplate - Use this template for elements that are rendered every other row of data. This allows you to alternate background colors, for example.

· HeaderTemplate - Use this template for elements that you want to render once before your ItemTemplate section.

· FooterTemplate - Use this template for elements that you want to render once after your ItemTemplate section.

· SeperatorTemplate - Use this template for elements to render between each row, such as line breaks.

For more details please check this url...


:cool:The Repeater control is used to display a repeated list of items that are bound to the control. It enable the customization of the layout by each repeated list of items. The Repeater control may be bound to a database table, an XML file, or another list of items. The Repeater control has no built-in select and edit support.
But possible to edit,update,delete and update in repeater control. Most of the developers didn't know about this, but yes it is posible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.