protected void GdvAD_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         AdvertisementInfo dataItem = (AdvertisementInfo)e.Row.DataItem;
         Label             label    = (Label)e.Row.FindControl("LabViews");
         Label             label2   = (Label)e.Row.FindControl("LabClicks");
         Label             label3   = (Label)e.Row.FindControl("LabDays");
         HyperLink         link     = (HyperLink)e.Row.FindControl("HypPreview");
         link.NavigateUrl = "PreviewAD.aspx?Type=Ad&AdId=" + dataItem.ADId;
         Label label4 = (Label)e.Row.FindControl("LabRate");
         if (dataItem.Clicks == 0)
         {
             label4.Text = "0%";
         }
         else if (dataItem.Views == 0)
         {
             label4.Text = "100%";
         }
         else
         {
             label4.Text = (((((float)dataItem.Clicks) / ((float)dataItem.Views)) * 100f)).ToString() + "%";
         }
         if (dataItem.ADType == 4)
         {
             link.Attributes.Add("onmouseover", "ShowADPreview(' 代码广告请点击预览 ')");
         }
         else
         {
             link.Attributes.Add("onmouseover", "ShowADPreview('" + Advertisement.GetAdContent(dataItem) + "')");
         }
         link.Attributes.Add("onmouseout", "hideTooltip('dHTMLADPreview')");
         if (dataItem.CountClick)
         {
             label2.Text = dataItem.Clicks.ToString();
         }
         else
         {
             label2.Text = "<font color='#999999'>不统计</font>";
         }
         if (dataItem.CountView)
         {
             label.Text = dataItem.Views.ToString();
         }
         else
         {
             label.Text = "<font color='#999999'>不统计</font>";
         }
         if (dataItem.Days >= 0)
         {
             label3.Text = dataItem.Days.ToString() + "天";
         }
         else
         {
             label3.Text = "<font color=\"red\">已经过期</font>";
         }
     }
 }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdvertisementInfo advertisementById = Advertisement.GetAdvertisementById(BasePage.RequestInt32("AdId"));

            if (!advertisementById.IsNull)
            {
                this.LabAdShow.Text = Advertisement.GetAdContent(advertisementById);
                if (advertisementById.CountClick)
                {
                    advertisementById.Clicks++;
                }
                if (advertisementById.CountView)
                {
                    advertisementById.Views++;
                }
                Advertisement.Update(advertisementById);
            }
        }
        private void ShowAd()
        {
            AdvertisementInfo advertisementById = Advertisement.GetAdvertisementById(BasePage.RequestInt32("AdId"));

            this.ShowJS.InnerHtml = Advertisement.GetAdContent(advertisementById);
        }