Ejemplo n.º 1
0
        protected void rptData_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                Advertise objData = new Advertise();
                string    id      = e.CommandArgument.ToString();
                objData.Id = int.Parse(id);
                switch (e.CommandName)
                {
                case "Edit":
                    Response.Redirect("AdvertiseAdd.aspx?Id=" + id, false);
                    break;

                case "Active":
                    string strA   = "";
                    string active = e.CommandArgument.ToString();
                    id             = ((HiddenField)e.Item.FindControl("hdId")).Value;
                    strA           = active == "1" ? "0" : "1";
                    objData.Id     = int.Parse(id);
                    objData.Active = int.Parse(strA);
                    objData.UpdateActive();
                    BinData();
                    break;

                case "Delete":
                    objData.Delete(id);
                    BinData();
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         string listId = "";
         foreach (RepeaterItem item in rptData.Items)
         {
             if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item)
             {
                 if (((HtmlInputCheckBox)item.FindControl("chkItem")).Checked)
                 {
                     string    strId   = ((HiddenField)item.FindControl("hdId")).Value;
                     Advertise objData = new Advertise();
                     objData.Delete(strId);
                 }
             }
         }
         BinData();
     }
     catch (Exception)
     {
         throw;
     }
 }