Sunday, March 6, 2011

pass argument in imagebutton inside gridview

aspx code
protected void btn_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton btn = (ImageButton)sender;

            int id = Convert.ToInt32(btn.CommandArgument.ToString());

            switch (btn.CommandName.ToString())
            { 
            
                case "Edit":
                    Session["customer_id"] = id;
                    //Response.Redirect("~/Customer/CustomerDetails.aspx");
                    Response.Redirect("~/Customer/CustomerDetails.aspx");
                    break;
                case "Delete":
                    
                    Session["customer_id"] = id;

                    var cust = new CRM.Lib.Customer(); 
                    cust.Delete(Convert.ToInt32(Session["customer_id"].ToString()));
                    RefreshList();
                    break;
            }
        }

1 comment: