asp:linkbutton

Discussion in 'Software' started by stevejhon, 7 Oct 2008.

  1. stevejhon

    stevejhon What's a Dremel?

    Joined:
    7 Oct 2008
    Posts:
    1
    Likes Received:
    0
    Hello I had problem

    I want to delete row from my datatable through asp:linkbutton. How can I do this. I had the following code, but it adds another row to the table

    protected void delCart(object s, DataTableNewRowEventArgs e)
    {
    dt = (DataTable)Session["Cart"];
    dt.Rows[e.Item.ItemIndex].Delete();
    //dt.Rows(e.Item.ItemIndex).Delete();

    int CartItem = (int)Session["cartItem"];
    CartItem = CartItem - 1;
    Session["cartItem"] = CartItem;
    Session["Cart"] = dt;
    DataList1.DataSource = dt;
    DataList1.DataBind();
    updateCart();
    Response.Redirect("ShoppingCart.aspx");

    }

    The updateCart() just updates the cart values.
     
  2. shazzmerc

    shazzmerc What's a Dremel?

    Joined:
    13 Oct 2008
    Posts:
    1
    Likes Received:
    0
    Hi Steve,
    Try This one I hope it will be suitable for your requirement.
    dt.AcceptChanges();
    after
    dt.Rows[e.Item.ItemIndex].Delete();

    Regards;
    shazz


    .Net Consultant

    Phone: (212) 736-3333
     

Share This Page