Example #1
0
    protected void LoadView()
    {
        string[] itemNames  = System.Enum.GetNames(typeof(BunnerType));
        Array    itemValues = System.Enum.GetValues(typeof(BunnerType)).Cast <int>().ToArray();

        for (int i = 0; i <= itemValues.Length - 1; i++)
        {
            string   localizationValue = ResourceManagerAccessor.GetText("Advertisements", itemNames[i]);
            ListItem item = new ListItem(localizationValue, itemValues.GetValue(i).ToString());
            ddlBunner.Items.Add(item);
        }
        ddlBunner.DataBind();
        ddlBusinessName.DataSource     = AdvertisementController.GetAllCompanies();
        ddlBusinessName.DataValueField = "Key";
        ddlBusinessName.DataTextField  = "Value";
        ddlBusinessName.DataBind();

        if (AdId > 0)
        {
            Advertisement advertisement = Advertisement.FetchByID(AdId);

            ddlBusinessName.SelectedValue = advertisement.CompanyId.ToString();
            txtFromDate.Text = advertisement.FromDate.ToString();
            txtToDate.Text   = advertisement.ToDate.ToString();
            href.Text        = advertisement.Href;

            ddlBunner.SelectedValue = ((int)advertisement.BunnerId).ToString();

            if (!string.IsNullOrEmpty(advertisement.FilePath))
            {
                HomeImage.ImageUrl = MediaUtility.GetImagePath("Banners", advertisement.FilePath, 0, 64, 64);
                HomeImage.ImageUrl = HomeImage.ImageUrl.Contains(".") ? HomeImage.ImageUrl : "";
                ImageFileHandler(fuImage, HomeImage, btnDeleteImage, HomeImage.ImageUrl);
            }
        }
    }