示例#1
0
 protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         Product product        = (Product)e.Row.DataItem;
         Label   lbProductType  = (Label)e.Row.FindControl("lbProductType");
         Label   lbManufacturer = (Label)e.Row.FindControl("lbManufacturer");
         Label   lbName         = (Label)e.Row.FindControl("lbName");
         if (lbProductType != null)
         {
             if (product.ProductType != null)
             {
                 lbProductType.Text = product.ProductType.Name;
             }
         }
         if (lbManufacturer != null)
         {
             if (product.Manufacturer != null)
             {
                 lbManufacturer.Text = product.Manufacturer.Name;
             }
         }
         if (lbName != null)
         {
             lbName.Text    = ToSQL.ShortString(product.Name, 32);
             lbName.ToolTip = product.Name;
         }
         int      Id = ToSQL.SQLToInt(gvProducts.DataKeys[e.Row.RowIndex].Value.ToString());
         DataList dtlImagesProduct = e.Row.FindControl("dtlImagesProduct") as DataList;
         dtlImagesProduct.DataSource = (new ProductImageRepo()).GetAllImagesByProductId(Id);
         dtlImagesProduct.DataBind();
     }
 }
示例#2
0
 protected void gvProductPriceHistorys_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         ProductPriceHistory productPriceHistory = (ProductPriceHistory)e.Row.DataItem;
         Label lbProductType  = (Label)e.Row.FindControl("lbProductType");
         Label lbManufacturer = (Label)e.Row.FindControl("lbManufacturer");
         Label lbProductName  = (Label)e.Row.FindControl("lbProductName");
         if (productPriceHistory.Product != null)
         {
             if (lbProductType != null)
             {
                 if (productPriceHistory.Product.ProductType != null)
                 {
                     lbProductType.Text = productPriceHistory.Product.ProductType.Name;
                 }
             }
             if (lbManufacturer != null)
             {
                 if (productPriceHistory.Product.Manufacturer != null)
                 {
                     lbManufacturer.Text = productPriceHistory.Product.Manufacturer.Name;
                 }
             }
             if (lbProductName != null)
             {
                 lbProductName.Text    = ToSQL.ShortString(productPriceHistory.Product.Name, 32);
                 lbProductName.ToolTip = productPriceHistory.Product.Name;
             }
         }
     }
 }