When I select a product and added this to my cart , user can go to the cart page and edit the product. 

If Edit is true I call the LoadValues and setup customised product.

For every extras in a product I create a ProductPropertiesCell and I add a values for this extra. (e.g Sugar -> No Sugar)

> 
> ProductDetailsController.cs
> 
> 
> 

```
    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();

        ProductDetailsTable.Source = new ProductDetailsTableSource (this, SelectedProduct);
        ProductDetailsTable.ReloadData ();

        if (Edit) {
            ((ProductDetailsTableSource)ProductDetailsTable.Source).LoadValues (ProductDetailsTable);
        }

    }

```

Console output after LoadValues called.

> 
> 1
> 
> 
> 2
> 
> 
> 3
> 
> 
> 4 
>  extra 7 
> 
> 
> 5
>  extra 10
> 
> 
> 

For every cell i write the tag and the value which is added to this. 

> 
> ProductDetailsTableSource.cs
> 
> 
> 

```
public class ProductDetailsTableSource : UITableViewSource
{
    NSString cellIdentifier;

    public Product SelectedProduct { get; set; }

    public ProductDetailsController Parent
    {
        get;
        set;
    }

    public ProductDetailsTableSource(ProductDetailsController parent, Product product)
    {
        Parent = parent;
        SelectedProduct = product;
    }

    public override nint NumberOfSections(UITableView tableView)
    {
        return SelectedProduct.Types.Count + 3; //+3 for description, quantity, comment cell
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return 1;
    }

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        // Product Description
        if (indexPath.Section == 0)
        {
            cellIdentifier = new NSString("descriptionCell"); 
            var cell = tableView.DequeueReusableCell(cellIdentifier) as ProductDescriptionCell;
            cell.UpdateCell(SelectedProduct);

            return cell;
        }

        // Properties or Product Type Cell
        if (indexPath.Section <= SelectedProduct.Types.Count)
        {
            cellIdentifier = new NSString("propertiesCell"); 
            var cell = tableView.DequeueReusableCell(cellIdentifier) as ProductPropertiesCell;
            cell.UpdatePicker (this, SelectedProduct.Types [indexPath.Section - SelectedProduct.Props.Count - 1], indexPath);
            cell.Tag = indexPath.Section;
            return cell;
        }

        // Comments
        if (indexPath.Section == SelectedProduct.Types.Count + 1)
        {
            cellIdentifier = new NSString ("commentsCell");
            var cell = tableView.DequeueReusableCell (cellIdentifier) as CommentsCell;
            cell.Setup (tableView, indexPath);

            return cell;
        }

        // Quantity
        else {
            cellIdentifier = new NSString ("quantityCell");
            var cell = tableView.DequeueReusableCell (cellIdentifier) as QuantityCell;
            cell.UpdateData (Parent);
            return cell;
        } 

    }

    public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
    {
        tableView.DeselectRow(indexPath, true);
    }

    public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
    {
        //Description
        if(indexPath.Section==0)
        {
            if (string.IsNullOrWhiteSpace (SelectedProduct.Desc))
                return 0;
            else
            return UITableView.AutomaticDimension;
            //return 80;
        }

        //pickers
        if (indexPath.Section <= SelectedProduct.Types.Count)
            return 80;

        //Comments
        if (indexPath.Section == SelectedProduct.Types.Count + 1)
        return 100;

        //Quantity
        if (indexPath.Section == SelectedProduct.Types.Count + 2)
            return 64;

        return 0;
    }

    public void LoadValues (UITableView tableView)
    {

        for (nint i = 1; i <= SelectedProduct.Types.Count; i++) {
            // we scroll to force our cells to be visible else they return null
            tableView.ScrollRectToVisible (tableView.RectForSection (i), true);

            var cell = ((ProductPropertiesCell)tableView.CellAt (NSIndexPath.FromRowSection (0, i)));
            Debug.WriteLine (cell.Tag);
            Debug.WriteLine (Parent.Info.SavedProductInstance [i]);
            cell.ValuePicked = Parent.Info.SavedProductInstance [i];

        }

        tableView.ScrollRectToVisible (tableView.RectForSection ((nint)SelectedProduct.Types.Count + 1), true);
        ((CommentsCell)tableView.CellAt (NSIndexPath.FromRowSection (0, (nint)SelectedProduct.Types.Count + 1))).Comments = Parent.OrderProduct.Comments;
        tableView.ScrollRectToVisible (tableView.RectForSection ((nint)SelectedProduct.Types.Count + 2), true);
        ((QuantityCell)tableView.CellAt (NSIndexPath.FromRowSection (0, (nint)SelectedProduct.Types.Count + 2))).Quantity = Parent.Info.Quantity;

        BeginInvokeOnMainThread (()=> tableView.ScrollRectToVisible (tableView.RectForSection (0), true));

    }

}

```

> 
> ProductPropertiesCell.cs
> 
> 
> 
> ```
>     public string ValuePicked
>     { 
>         get { return Picker.Text; }
>         set { Picker.Text = value; }
>     }
> 
> ```
> 
> 

When cells are too much and don't fit to screen then the values are rendered in a different cells.

[![enter image description here](https://i.stack.imgur.com/SvsT9.png)](https://i.stack.imgur.com/SvsT9.png)

When all cells fit to screen, it's working perfect.