protected void Page_Load(object sender, EventArgs e)
 {
     MediaComposers dal = new MediaComposers(StoredData);
     if (!Page.IsPostBack)
     {
         LoadStatus2DDL();
         PageAndBind(GridView1);
     }
 }
        private int UpdateData()
        {
            string user_id = Session["UserId"].ToString();
            string composer_name = txtComposerName.Text;
            string description = txtDescription.Text;
            string status = rdlStatus.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_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;
                string folderchild = Orginal_front_image.Substring(0, 10);
                DeleteFrontImage(Orginal_front_image);
                DeleteMainImage(Orginal_main_image);
            }
            else
            {
                front_image = Orginal_front_image;
                main_image = Orginal_main_image;
            }
            ////========================================================================================================================


            MediaComposers artist_obj = new MediaComposers();
            int i = artist_obj.Update(_idx, user_id, composer_name, front_image, main_image, description, status);
            return i;
        }
        private int AddData()
        {
            string user_id = Session["UserId"].ToString();
            string composer_name = txtComposerName.Text;
            string description = txtDescription.Text;
            string status = rdlStatus.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;
            }
            ////========================================================================================================================

            MediaComposers artist_obj = new MediaComposers();
            int i = artist_obj.Insert(user_id, composer_name, front_image, main_image, description, status);
            return i;
        }
        private void LoadData()
        {
            MediaComposers artist_obj = new MediaComposers();
            Media_Composers 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;

            txtComposerName.Text = entity.ComposerName;
            txtDescription.Text = entity.Description;
            string Status = entity.Status;
            PopulateStatus2DDL(Status);
        }
 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";
     MediaComposers composer_obj = new MediaComposers();           
     composer_obj.UpdateStatus(UserId, key, Status);
     //composer_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
 }