'I'm trying to expand the Datagrid when adding another value. Using Xamarin.Forms.Datagrid
I'm using Xamarin.Forms.Datagrid. What I'm struggling with is displaying the second row. I suspect it is in the adding value part that I'm not specifying to add a new row to the Datagrid. But for the life of me I can't see it.
Now if I scanned a different barcode. It adds the new value to the collection but does not expand the datagrid.
My ObservableCollection:
public ObservableCollection<dgvProductionReceiptSource> ProductionReceiptSource { get; } = new ObservableCollection<dgvProductionReceiptSource>();
Where I get my data from:
private void FillDataGrid()
{
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("SELECT DocNum, OWOR.ItemCode, ItemName, PlannedQty, CAST(OWOR.DueDate AS DATE) FROM OWOR " +
"INNER JOIN OITM ON OWOR.ItemCode = OITM.ItemCode WHERE Status = 'R' AND OWOR.DocNum = '" + ScanBarcodeText + "' ORDER BY DueDate ASC", connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader != null)
{
while (reader.Read())
{
ItemNum = reader.GetString(1);
Desc = reader.GetString(2);
PlannedQty = reader.GetDecimal(3);
DueDate = reader.GetDateTime(4);
ScanQty = 0;
if (DueDate == DateTime.Today)
{
if (DocNum.ToString() == ScanBarcodeText)
{
AddQty();
}
if (DocNum.ToString() != ScanBarcodeText)
{
DocNum = reader.GetInt32(0);
ProductionReceiptSource.Add(new dgvProductionReceiptSource()
{
DocNumProductionReceipt = DocNum,
ItemNumberProductionReceipt = reader.GetString(1),
DescriptionProductionReceipt = reader.GetString(2),
PlannedQuantityProductionReceipt = reader.GetDecimal(3),
ScannedQuantityProductionReceipt = 0
});
AddQty();
}
}
}
}
}
}
connection.Close();
}
ScanBarcodeText = string.Empty;
}
catch(Exception ex)
{
Application.Current.MainPage.DisplayAlert("Alert", ex.Message, "OK");
}
}
Any help would be appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


