protected void Page_Load(object sender, EventArgs e) { MediaPlayLists dal = new MediaPlayLists(StoredData); if (!Page.IsPostBack) { LoadStatus2DDL(); PageAndBind(GridView1); } }
protected void PopulateMediaPlayList2DDL(string selected_value) { MediaPlayLists media_playlist_obj = new MediaPlayLists(); List<Media_PlayLists> lst = media_playlist_obj.GetListByStatus("1"); ddlPlayList.Items.Clear(); ddlPlayList.DataSource = lst; ddlPlayList.DataTextField = "PlayListName"; ddlPlayList.DataValueField = "PlayListId"; ddlPlayList.DataBind(); ddlPlayList.SelectedValue = selected_value; ddlPlayList.AutoPostBack = true; }
private int UpdateData() { string user_id = Session["UserId"].ToString(); string playlist_name = txtPlayListName.Text; string description = txtDescription.Text; string status = rdlStatus.SelectedValue; int typeid = Convert.ToInt32(ddlMediaTypeList.SelectedValue); /*** UPLOAD ************************************************************************************************************/ string[] FileImg = new String[2]; string front_image = string.Empty; string main_image = string.Empty; string front_path = Server.MapPath(upload_front_image_dir); string main_path = Server.MapPath(upload_main_image_dir); string Orginal_front_image = ViewState["FrontImage"].ToString(); string Orginal_main_image = ViewState["MainImage"].ToString(); //if (FileUpload1.HasFile) if (Session["FileUpload1"] != null && Session["FileUpload1"].ToString() != string.Empty) { FileHandleClass file_obj = new FileHandleClass(); FileImg = file_obj.upload_front_main_image(FileUpload1, front_path, main_path, 120, 120); main_image = FileImg[0]; front_image = FileImg[1]; //System.Drawing.Image img1 = System.Drawing.Image.FromFile(front_path+ "/" + front_image); imgPhoto.ImageUrl = upload_front_image_dir + "/" + front_image; string folderchild = Orginal_front_image.Substring(0, 10); file_obj.DeleteFile(Orginal_front_image, upload_front_image_dir); file_obj.DeleteFile(Orginal_main_image, upload_main_image_dir); } else { front_image = Orginal_front_image; main_image = Orginal_main_image; } ////======================================================================================================================== MediaPlayLists artist_obj = new MediaPlayLists(); int i = artist_obj.Update(_idx, typeid, user_id, playlist_name, front_image, main_image, description, status); return i; }
private int AddData() { string user_id = Session["UserId"].ToString(); string playlist_name = txtPlayListName.Text; string description = txtDescription.Text; string status = rdlStatus.SelectedValue; int typeid = Convert.ToInt32(ddlMediaTypeList.SelectedValue); /*** UPLOAD ************************************************************************************************************/ string[] FileImg = new String[2]; string front_image = string.Empty; string main_image = string.Empty; string front_path = Server.MapPath(upload_front_image_dir); string main_path = Server.MapPath(upload_main_image_dir); if (FileUpload1.HasFile) { FileHandleClass file_bj = new FileHandleClass(); FileImg = file_bj.upload_front_main_image(FileUpload1, front_path, main_path, 120, 120); main_image = FileImg[0]; front_image = FileImg[1]; //System.Drawing.Image img1 = System.Drawing.Image.FromFile(front_path+ "/" + front_image); imgPhoto.ImageUrl = upload_front_image_dir + "/" + front_image; } ////======================================================================================================================== MediaPlayLists artist_obj = new MediaPlayLists(); int i = artist_obj.Insert(user_id, typeid, playlist_name, front_image, main_image, description, status); return i; }
private void LoadData() { MediaPlayLists artist_obj = new MediaPlayLists(); Media_PlayLists entity = artist_obj.GetDetails(_idx); string FrontImage = entity.FrontImage; string MainImage = entity.MainImage; imgPhoto.ImageUrl = upload_front_image_dir + "/" + FrontImage; ViewState["FrontImage"] = FrontImage; ViewState["MainImage"] = MainImage; txtPlayListName.Text = entity.PlayListName; txtDescription.Text = entity.Description; string Status = entity.Status; PopulateStatus2DDL(Status); string TypeId = ddlMediaTypeList.SelectedValue; PopulateMediaTypeList2DDL(TypeId); }
private void PageAndBind(GridView gv) { IList<Object> list = new List<Object>(); int pageSize = 2; int startRow = (gv.PageIndex * pageSize); string status = ddlStatus.SelectedValue; MediaPlayLists playList_obj = new MediaPlayLists(); IList<Media_PlayLists> data = playList_obj.LoadDatedItemsByPage(status, startRow, pageSize, GridViewSortBy, GridViewSortAscending); //copy data into generic list foreach (Media_PlayLists item in data) list.Add(item); int count = playList_obj.LoadDatedItemsCount(); //you could cache this //here's the bit where we use create an ODS in code to fill the gridview with paged data CommonLibrary.UI.GridView.GridViewFiller.Fill(gv, list, count, pageSize); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridView gv = (GridView)sender; //to get index and row int rowIndex = e.RowIndex; //here we have the row directly //GridViewRow row = gv.Rows[rowIndex]; //the row int key = (int)gv.DataKeys[rowIndex][0]; //int key = Convert.ToInt32(gv.DataKeys[e.RowIndex].Values[0].ToString()); //int key = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); string UserId = Session["UserId"].ToString(); string Status = "1"; MediaPlayLists playList_obj = new MediaPlayLists(); playList_obj.UpdateStatus(UserId, key, Status); //playList_obj.Delete(key); if (rowIndex == 0 && gv.Rows.Count == 1) gv.PageIndex = gv.PageIndex - 1; //only 1 item on page- page back PageAndBind(gv); //load the new information }