Related Tables database - new field

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hello,

I need 2 extra fields in the RelatedProduct table to show on the RelateProduct view in the SimpleProduct box.

I'm getting an error and I don't know enough about what I'm doing to fix the ToString error.  Any help would be greatly, greatly appreciated.



http://www.parts.troyonlinesales.com/codeerror2.png

Here's a couple links to the code.

Thanks,
Dave
5 years ago
When you look at the database the FigRef field - is it defined as an Integer or String ?
Seems to be a mismatch in the definition
i.e. Website is defined as Int and maybe the Database is a string ?
Or maybe the field in the database is null so it cannot be converted to int - check the value in the field
5 years ago
Hello and thanks for the reply.  I fixed that definition problem and have gotten this far (but have errors when I try to display the FigRef).

Domain Controller RelatedProduct.cs
        /// <DAVE>
        /// Gets or sets the display order
        /// </summary>
        public string FigRef { get; set; }

        /// <DAVE>
        /// Gets or sets the display order
        /// </summary>
        public int Qty { get; set; }


Admin Controller ProductController.ca
            var relatedProducts = _productService.GetRelatedProductsByProductId1(productId, true);
            var relatedProductsModel = relatedProducts
                .Select(x => new ProductModel.RelatedProductModel
                {
                    Id = x.Id,
                    //ProductId1 = x.ProductId1,
                    ProductId2 = x.ProductId2,
                    Product2Name = _productService.GetProductById(x.ProductId2).Name,
                    DisplayOrder = x.DisplayOrder,
                    FigRef = x.FigRef,
                    Qty = x.Qty

                })
                .ToList();


View _SimpleProductBox.cshtml
    <div class="item-details details">
        <h5 class="product-title">
            <a href="   ("Product", new { SeName = Model.SeName })">@Model.Name</a>  
            ********* Show FigRef and Qty here **********

        </h5>
    </div>
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.