Exemple #1
0
    protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        // weonly process commands with a datasource (our image buttons)
        if (e.CommandSource == null)
        {
            return;
        }
        string typeOfControl = e.CommandSource.GetType().ToString();

        if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton"))
        {
            int         id   = 0;
            ImageButton imgb = (ImageButton)e.CommandSource;
            if (imgb.ID != "New" && imgb.ID != "Exit")
            {
                id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]];
            }
            switch (imgb.ID)
            {
            case "Select":
                break;

            case "Edit":
                break;

            case "Delete":
                inv = (from i in ctx.Invoices
                       where i.InvoiceId == id
                       select i).FirstOrDefault <Invoice>();
                if (!CntAriCli.DeleteInvoice(inv, ctx))
                {
                    lblMessage.Text = Resources.GeneralResource.DeleteInvoiceFailed;
                    return;
                }
                lblMessage.Text = "";
                ctx.SaveChanges();
                RefreshGrid(true);
                break;
            }
        }
    }