protected void grdListImg_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": Id = strCA; List <Data.ImagesDetail> listE = ImagesDetailBUS.ImageDetail_GetById(Id); txtId.Text = strCA; txtName.Text = listE[0].Name; txtsummary.Text = listE[0].Summary; if (listE[0].Image.Length > 0) { txtImage.Text = listE[0].Image; imgImage.Visible = true; imgImage.ImageUrl = listE[0].Image; } //if (listE[0].Image.Length > 0) //{ // txtImagesmall.Text = listE[0].Image; // Image1.Visible = true; // Image1.ImageUrl = listE[0].Image; //} //else //{ // trImages.Visible = false; //} //txtWidth.Text = listE[0].Width; //txtHeight.Text = listE[0].Height; txtLink.Text = listE[0].ImageId; txtsummary.Text = listE[0].Summary; chkActive.Checked = listE[0].Active == "1" || listE[0].Active == "True"; pnView.Visible = false; pnUpdate.Visible = true; break; case "Active": string strA = ""; string str = e.Item.Cells[2].Text; strA = str == "1" ? "0" : "1"; SqlDataProvider sql = new SqlDataProvider(); sql.ExecuteNonQuery("Update [ImagesDetail] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": Bus.ImagesDetailBUS.ImagesDetail_Delete(strCA); BindGrid(); break; case "Image": Response.Redirect("/Admins/ImagesDetail.aspx?ImagesId=" + strCA + ""); break; } }
private void BindGrid() { grdProductImage.DataSource = ImagesDetailBUS.ImagesDetail_GetByTop("", "Active = 1 and ImagesId= " + ImagesId, "Id"); grdProductImage.DataBind(); if (grdProductImage.PageCount <= 1) { grdProductImage.PagerStyle.Visible = false; } }
//public string checkImg(string urlImg) //{ // if (File.Exists(Server.MapPath(urlImg)) == false) // { // urlImg = "/App_Themes/Admin/images/nophoto.jpg"; // } // return urlImg; //} //private void loadimage( ) //{ // List<Data.ImgType> list = Bus.ImgTypeBUS.ImgType_GetByAll(); // if (list.Count > 0) // { // ddlPosition.Items.Clear(); // //ddlFilterPosition.Items.Clear(); // ddlPosition.Items.Add(new ListItem(" -- Chọn định dạng-- ", "")); // // ddlFilterPosition.Items.Add(new ListItem(" -- Chọn định dạng-- ", "")); // for (int i = 0; i < list.Count; i++) // { // ddlPosition.Items.Add(new ListItem(list[i].Name, list[i].Code)); // //ddlFilterPosition.Items.Add(new ListItem(list[i].Name, list[i].Code)); // } // } //} //public string ShowPosition(string str) //{ // string s = ""; // List<Data.ImgType> list = ImgTypeBUS.ImgType_GetByTop("", "Code=" + str + "", ""); // if (list.Count > 0) // { // s += list[0].Name; // } // return s; //} private void BindGrid() { grdListImg.DataSource = ImagesDetailBUS.ImageDetail_GetByAll(); grdListImg.DataBind(); if (grdListImg.PageCount <= 1) { grdListImg.PagerStyle.Visible = true; } }
protected void grdProductImage_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": txtId.Text = strCA; txtName.Text = ""; List <Data.ImagesDetail> ListE = ImagesDetailBUS.ImageDetail_GetById(strCA); txtImage.Text = ListE[0].Image.Length > 0 ? ListE[0].Image : ""; pnView.Visible = false; pnUpdate.Visible = true; break; case "Active": break; case "Delete": break; } }