Problems with asp:button

  • Thread starter Maziar Aflatoun
  • Start date
M

Maziar Aflatoun

Hi everyone,

I have the following shopping cart (basket view). However, Delete button in
my datagrid doesn't fire any events. Does anyone know why? (It's a user web
control)

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="ShoppingCart.ascx.cs" Inherits="TPShoppingCart.ShoppingCart1"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp:datagrid id="DGShoppingCart" AutoGenerateColumns="False" Width="650"
runat="server">
<Columns>
<asp:BoundColumn DataField="ProductID" HeaderText="Product ID"
HeaderStyle-Font-Bold="True" HeaderStyle-CssClass="normtext"
ItemStyle-CssClass="normtext"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductName" HeaderText="Product"
HeaderStyle-Font-Bold="True" HeaderStyle-CssClass="normtext"
ItemStyle-CssClass="normtext"></asp:BoundColumn>
<asp:BoundColumn DataField="Price" HeaderText="Price"
HeaderStyle-Font-Bold="True" HeaderStyle-CssClass="normtext"
DataFormatString="{0:c}" ItemStyle-CssClass="normtext"></asp:BoundColumn>
<asp:BoundColumn DataField="Qty" HeaderText="Quantity"
HeaderStyle-Font-Bold="True" HeaderStyle-CssClass="normtext"
ItemStyle-CssClass="normtext"></asp:BoundColumn>
<asp:ButtonColumn ButtonType="PushButton" CommandName="Delete"
Text="Delete"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
<P>&nbsp;</P>
<P class="normtext" align="center"><b>Total:</b>
<asp:label id="lblCurrencySign" runat="server"
CssClass="normtext">$</asp:label><asp:label id="lbTotalAmount"
runat="server" CssClass="normtext" Font-Bold="False">
Label</asp:label></P>
<P align="center"><asp:button id="BtnContinue" runat="server"
CssClass="button1" Text="Continue Shopping"></asp:button>&nbsp;
<asp:button id="BtnCheckout" runat="server" CssClass="button2"
Text="Checkout"></asp:button></P>

As a test I have,

private void DGShoppingCart_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Response.Redirect("http://www.google.com");
}

It's doesn't even get to the event.

Any suggestions?

Thank you
Maz.
 
S

scott AT scottcreynolds DOT com

Are you sure that you have the DataGrid's ItemCommand event wired up?
I've had problems in ASP.NET where the code for the eventwireup breaks
and goes away and I'm left with non-firing commands.
Scott C. Reynolds
Tales from the SharpSide
http://www.scottcreynolds.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top