protected void btnUpload_Click(object sender, EventArgs e)
        {
            int intError = 0;
            if (FileUpload1.HasFile)
            {
                string[] strTemp = new string[5];
                strTemp = strAllImgPath.Split(':');
                if (FileUpload1.PostedFile.ContentLength > 1048576)
                {
                    errFile1.Visible = true;
                    errFile1.Text = "Exceeds maximum limit 1 MB";
                    intError++;
                }
                else if (strTemp.Length == 5 && strTemp[4] != null && strTemp[4] != "")
                {
                    errFile1.Visible = true;
                    errFile1.Text = "Maximum 5 images are allowed. ";
                    intError++;
                }
                else
                    errFile1.Visible = false;
            }
            else
            {
                string[] strTemp = new string[5];
                strTemp = strAllImgPath.Split(':');
                if (strTemp.Length == 5 && strTemp[4] != null && strTemp[4] != "")
                {
                    errFile1.Visible = true;
                    errFile1.Text = "Maximum 5 images are allowed. ";
                    intError++;
                }
                else
                {
                    errFile1.Visible = true;
                    errFile1.Text = "Select a image file. ";
                    intError++;
                }
            }
            if (intError == 0)
            {
                string path = string.Empty;
                string finalPath = string.Empty;
                string filePath = string.Empty;
                int userId = Convert.ToInt32(Session["UserId"].ToString());
                string sFilename = "";
                if (FileUpload1.PostedFile != null)
                {
                    HttpPostedFile myFile = FileUpload1.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen != 0)
                    {
                        DirectoryInfo dirInfo = null;
                        string fileSavePath = "/Data/TS_" + userId + "/Images/";
                        path = Server.MapPath("~" + fileSavePath);
                        if (!Directory.Exists(path))
                        {
                            dirInfo = Directory.CreateDirectory(path);
                        }
                        sFilename = System.IO.Path.GetFileName(myFile.FileName);
                        path = path + "/" + sFilename;
                        FileUpload1.PostedFile.SaveAs(path);

                        finalPath = Path.Combine(fileSavePath, sFilename);
                    }
                    if (strAllImgPath.Trim() == "")
                        strAllImgPath = finalPath;
                    else
                        strAllImgPath = strAllImgPath + ":" + finalPath;

                    YardeCartData.AdImageDetails adimg = new YardeCartData.AdImageDetails();
                    adimg.ImageId = Convert.ToInt32(strImageId);
                    adimg.ImagePath = strAllImgPath;
                    objYser.UpdateAdImagePath(adimg);

                    BindUrl();

                }
            }
        }
        protected void remove5_Click(object sender, EventArgs e)
        {
            string sourcepath = string.Empty;
            DirectoryInfo dirInfo = null;
            string Path1 = remove5.Attributes["imgpath"].ToString();
            sourcepath = Server.MapPath("~" + Path1);

            FileInfo g = new FileInfo(sourcepath);
            if (g.Exists)
                g.Delete();

            int index = strAllImgPath.IndexOf(Path1);
            int leng = Path1.Length;
            int newlength = 0;
            int newindex = 0;

            if (index + leng == strAllImgPath.Length && index == 0)
            {
                newindex = index;
                newlength = leng;
            }
            else if (index + leng == strAllImgPath.Length && index != 0)
            {
                newindex = index - 1;
                newlength = leng + 1;
            }
            else
            {
                newindex = index;
                newlength = leng + 1;
            }

            YardeCartData.AdImageDetails adimg = new YardeCartData.AdImageDetails();
            adimg.ImageId = Convert.ToInt32(strImageId);
            adimg.ImagePath = strAllImgPath.Remove(newindex, newlength);
            objYser.UpdateAdImagePath(adimg);
            BindUrl();
        }
        protected void btnSaveAd_Click(object sender, EventArgs e)
        {
            //string str = fileuploadImg.PostedFile.FileName;
            HttpFileCollection fileCollection = Request.Files;
            for (int i = 0; i < fileCollection.Count; i++)
            {
                HttpPostedFile uploadfile = fileCollection[i];
                string fileName = Path.GetFileName(uploadfile.FileName);
            }
            YardeCartData.UserDetails usr = new YardeCartData.UserDetails();
            usr.UserId = Convert.ToInt32(strUserId);
            dt = objYser.SelectUserProfile(usr); // userid
            try
            {

                #region .. CREATE AD POST ..
                YardeCartData.AdPostDetails ad = new YardeCartData.AdPostDetails();
                ad.AdPostId = Convert.ToInt32(strAdpostId);
                ad.AdPostTitle = txtTitle.Text.ToString();
                ad.Description = txtDesc.Text.ToString();
                ad.Keywords = txtKeywords.Text.ToString();
                ad.UserId = Convert.ToInt32(strUserId);
                ad.CategoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString());
                ad.Price = txtPrice.Text.ToString();
                ad.StateId = Convert.ToInt32(dt.Rows[0]["StateId"].ToString());
                ad.CityId = Convert.ToInt32(dt.Rows[0]["CityId"].ToString());
                ad.CountryId = Convert.ToInt32(dt.Rows[0]["CountryId"].ToString());
                ad.ZipCode = dt.Rows[0]["ZipCode"].ToString();
                ad.AdTillDate = txtShowDate.Value;
                ad.AdStatus = "NEW";
                ad.PaidStatus = 0;
                int intAdpostId = objYser.AddAdPost(ad);

                #endregion

                YardeCartData.AdImageDetails adimg=new YardeCartData.AdImageDetails();
                adimg.AdPostId=Convert.ToInt32(strAdpostId);
                adimg.ImageId= Convert.ToInt32(strImageId);
                adimg.ImagePath=strAllImgPath;
                adimg.VideoLink = txtVidolink.Text.ToString();
                objYser.AddAdImageDetails(adimg);

                if (dt.Rows[0]["UserStatus"].ToString()=="1")
                    Response.Redirect("MyHome.aspx?page=adpost");
                else if (dt.Rows[0]["UserStatus"].ToString() == "2")
                    Response.Redirect("MyAdminHome.aspx?page=adpost");

            }
            catch (System.Threading.ThreadAbortException th)
            {
            }
            catch (Exception ex)
            {
            }
        }