on 2022 Feb 23 2:25 PM
Hello,
I am trying to set values in a matrix combobox but I get this error: Error: 'String was not recognized as a valid DateTime.'
The values I get from the DB are as follows:
The matrix column is bound to a datatype date user datasource as below.
How do I fix this error? This is my code below:
_expDate = _form.DataSources.UserDataSources.Add("iV_15", SAPbouiCOM.BoDataType.dt_DATE, 100);
oIColumns = oIMatrix.Columns;
_colExpDate = oIColumns.Item("iV_15");
_colExpDate.DataBind.SetBound(true, "", "iV_15");
#region Item Change Event Expiry dates
_cmbExpDate = (SAPbouiCOM.ComboBox)oIMatrix.Columns.Item("iV_15").Cells.Item(pVal.Row).Specific;
int count = _cmbExpDate.ValidValues.Count;
if (count > 0)
{
_expDate.ValueEx = "";
for (int j = 0; j <= count - 1; j++)
_cmbExpDate.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index);
}
var expDates = (from oi in _db.OITMs
join ob in _db.OBTNs
on oi.ItemCode equals ob.ItemCode
where ob.ItemCode == _itemNo.ValueEx && oi.OnHand > 0
orderby ob.ExpDate
select new
{
ExpDate = ob.ExpDate
}).Distinct().ToList();
if (expDates.Count > 0)
{
foreach (var item in expDates)
_cmbExpDate.ValidValues.Add(item.ExpDate?.ToString("yyyyMMdd"), item.ExpDate?.ToString("yyyyMMdd"));
//_cmbExpDate.Select(0, SAPbouiCOM.BoSearchKey.psk_Index);
//_expDate.ValueEx = _cmbExpDate.Value;
}
#endregion
Any help appreciated.
Kinyanjui
Hi sapinkenya,
Following code works fine for EditText:
oEdit.Value = DateTime.Now.ToString("yyyyMMdd");
Can you try the same with ComboBox in "yyyyMMdd" format and share the results with us?
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.