Tom Knowlton
asked on
Assigning List<T> to a DataGridView.DataSource - data seems to be there, but grid is blank
If you look at the screenshot below, I've got the code stopped just after the assignment of the List<T> to the DataGridView.DataSource.
The DataSource in the Watch window shows a count of 95 items, and if I expand that list, each item has the correct data.
What am I missing? : /
MemParts:
The DataSource in the Watch window shows a count of 95 items, and if I expand that list, each item has the correct data.
What am I missing? : /
MemParts:
public class MemParts
{
public MemParts() { }
public void InitMemPartsAsPreview()
{
CustID = -1;
PartNumber = "";
Description = "";
TypeID = GlobalDatabaseHelperMethods.GetCellInfo("PartTypes", "PartTypesID", "where Label = 'RAW'", "int").ToString().ExToInt32();
UMID = GlobalDatabaseHelperMethods.GetCellInfo("UnitMeasureTypes", "UnitMeasureID", "where Label = 'EA'", "int").ToString().ExToInt32();
ClassID = -1;
NumberOfLeads = -1;
CommmonStock = false;
RoHS = true;
AllowCrossesID = GlobalDatabaseHelperMethods.GetCellInfo("AllowCrossesTypes", "AllowCrossesID", "where Label = 'APPROVE'", "int").ToString().ExToInt32();
PackageReqID = -1;
StatusID = -1;
Notes = "";
HasSafetyStock = false;
ReorderTrigger = 0.00;
ReorderQnty = 0.00D;
OtherNotes = "";
}
public int CustID = -1;
public string PartNumber = "";
public string Description = "";
public int TypeID = -1;
public int UMID = -1;
public int ClassID = -1;
public int NumberOfLeads = -1;
public bool CommmonStock = false;
public bool RoHS = true;
public int AllowCrossesID = -1;
public int PackageReqID = -1;
public int StatusID = -1;
public string Notes = "";
public bool HasSafetyStock = false;
public double ReorderQnty = 0.00D;
public string OtherNotes = "";
public double ReorderTrigger = 0.00;
}//end of class
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There was no issue with auto-generated columns, but something to keep in mind.
Creating properties for the fields did the trick, thank you!
[code]
public class MemParts
{
public MemParts() { }
public MemParts(int custID, string partNumber, string description, int typeID, int umid, int classID, int numberOfLeads, bool commmonStock, bool rohs, int allowCrossesID, int packageReqID, int statusID, string notes, bool hasSafetyStock, double reorderQnty, string otherNotes, double reorderTrigger)
{
CustID = custID;
PartNumber = partNumber;
Description = description;
TypeID = typeID;
UMID = umid;
ClassID = classID;
NumberOfLeads = numberOfLeads;
CommmonStock = commmonStock;
RoHS = rohs;
AllowCrossesID = allowCrossesID;
PackageReqID = packageReqID;
StatusID = statusID;
Notes = notes;
HasSafetyStock = hasSafetyStock;
ReorderQnty = reorderQnty;
OtherNotes = otherNotes;
ReorderTrigger = reorderTrigger;
}
public void InitMemPartsAsPreview()
{
CustID = -1;
PartNumber = "";
Description = "";
TypeID = GlobalDatabaseHelperMethod s.GetCellI nfo("PartT ypes", "PartTypesID", "where Label = 'RAW'", "int").ToString().ExToInt3 2();
UMID = GlobalDatabaseHelperMethod s.GetCellI nfo("UnitM easureType s", "UnitMeasureID", "where Label = 'EA'", "int").ToString().ExToInt3 2();
ClassID = -1;
NumberOfLeads = -1;
CommmonStock = false;
RoHS = true;
AllowCrossesID = GlobalDatabaseHelperMethod s.GetCellI nfo("Allow CrossesTyp es", "AllowCrossesID", "where Label = 'APPROVE'", "int").ToString().ExToInt3 2();
PackageReqID = -1;
StatusID = -1;
Notes = "";
HasSafetyStock = false;
ReorderTrigger = 0.00;
ReorderQnty = 0.00D;
OtherNotes = "";
}
private int _custid = -1;
private string _partnumber = "";
private string _description = "";
private int _typeid = -1;
private int _umid = -1;
private int _classid = -1;
private int _numberofleads = -1;
private bool _commmonstock = false;
private bool _rohs = true;
private int _allowcrossesid = -1;
private int _packagereqid = -1;
private int _statusid = -1;
private string _notes = "";
private bool _hassafetystock = false;
private double _reorderqnty = 0.00D;
private string _othernotes = "";
private double _reordertrigger = 0.00D;
public int CustID
{
get
{
return _custid;
}
set
{
_custid = value;
}
}
public string PartNumber
{
get
{
return _partnumber;
}
set
{
_partnumber = value;
}
}
public string Description
{
get
{
return _description;
}
set
{
_description = value;
}
}
public int TypeID
{
get
{
return _typeid;
}
set
{
_typeid = value;
}
}
public int UMID
{
get
{
return _umid;
}
set
{
_umid = value;
}
}
public int ClassID
{
get
{
return _classid;
}
set
{
_classid = value;
}
}
public int NumberOfLeads
{
get
{
return _numberofleads;
}
set
{
_numberofleads = value;
}
}
public bool CommmonStock
{
get
{
return _commmonstock;
}
set
{
_commmonstock = value;
}
}
public bool RoHS
{
get
{
return _rohs;
}
set
{
_rohs = value;
}
}
public int AllowCrossesID
{
get
{
return _allowcrossesid;
}
set
{
_allowcrossesid = value;
}
}
public int PackageReqID
{
get
{
return _packagereqid;
}
set
{
_packagereqid = value;
}
}
public int StatusID
{
get
{
return _statusid;
}
set
{
_statusid = value;
}
}
public string Notes
{
get
{
return _notes;
}
set
{
_notes = value;
}
}
public bool HasSafetyStock
{
get
{
return _hassafetystock;
}
set
{
_hassafetystock = value;
}
}
public double ReorderQnty
{
get
{
return _reorderqnty;
}
set
{
_reorderqnty = value;
}
}
public string OtherNotes
{
get
{
return _othernotes;
}
set
{
_othernotes = value;
}
}
public double ReorderTrigger
{
get
{
return _reordertrigger;
}
set
{
_reordertrigger = value;
}
}
}//end of class
[/code]
Creating properties for the fields did the trick, thank you!
[code]
public class MemParts
{
public MemParts() { }
public MemParts(int custID, string partNumber, string description, int typeID, int umid, int classID, int numberOfLeads, bool commmonStock, bool rohs, int allowCrossesID, int packageReqID, int statusID, string notes, bool hasSafetyStock, double reorderQnty, string otherNotes, double reorderTrigger)
{
CustID = custID;
PartNumber = partNumber;
Description = description;
TypeID = typeID;
UMID = umid;
ClassID = classID;
NumberOfLeads = numberOfLeads;
CommmonStock = commmonStock;
RoHS = rohs;
AllowCrossesID = allowCrossesID;
PackageReqID = packageReqID;
StatusID = statusID;
Notes = notes;
HasSafetyStock = hasSafetyStock;
ReorderQnty = reorderQnty;
OtherNotes = otherNotes;
ReorderTrigger = reorderTrigger;
}
public void InitMemPartsAsPreview()
{
CustID = -1;
PartNumber = "";
Description = "";
TypeID = GlobalDatabaseHelperMethod
UMID = GlobalDatabaseHelperMethod
ClassID = -1;
NumberOfLeads = -1;
CommmonStock = false;
RoHS = true;
AllowCrossesID = GlobalDatabaseHelperMethod
PackageReqID = -1;
StatusID = -1;
Notes = "";
HasSafetyStock = false;
ReorderTrigger = 0.00;
ReorderQnty = 0.00D;
OtherNotes = "";
}
private int _custid = -1;
private string _partnumber = "";
private string _description = "";
private int _typeid = -1;
private int _umid = -1;
private int _classid = -1;
private int _numberofleads = -1;
private bool _commmonstock = false;
private bool _rohs = true;
private int _allowcrossesid = -1;
private int _packagereqid = -1;
private int _statusid = -1;
private string _notes = "";
private bool _hassafetystock = false;
private double _reorderqnty = 0.00D;
private string _othernotes = "";
private double _reordertrigger = 0.00D;
public int CustID
{
get
{
return _custid;
}
set
{
_custid = value;
}
}
public string PartNumber
{
get
{
return _partnumber;
}
set
{
_partnumber = value;
}
}
public string Description
{
get
{
return _description;
}
set
{
_description = value;
}
}
public int TypeID
{
get
{
return _typeid;
}
set
{
_typeid = value;
}
}
public int UMID
{
get
{
return _umid;
}
set
{
_umid = value;
}
}
public int ClassID
{
get
{
return _classid;
}
set
{
_classid = value;
}
}
public int NumberOfLeads
{
get
{
return _numberofleads;
}
set
{
_numberofleads = value;
}
}
public bool CommmonStock
{
get
{
return _commmonstock;
}
set
{
_commmonstock = value;
}
}
public bool RoHS
{
get
{
return _rohs;
}
set
{
_rohs = value;
}
}
public int AllowCrossesID
{
get
{
return _allowcrossesid;
}
set
{
_allowcrossesid = value;
}
}
public int PackageReqID
{
get
{
return _packagereqid;
}
set
{
_packagereqid = value;
}
}
public int StatusID
{
get
{
return _statusid;
}
set
{
_statusid = value;
}
}
public string Notes
{
get
{
return _notes;
}
set
{
_notes = value;
}
}
public bool HasSafetyStock
{
get
{
return _hassafetystock;
}
set
{
_hassafetystock = value;
}
}
public double ReorderQnty
{
get
{
return _reorderqnty;
}
set
{
_reorderqnty = value;
}
}
public string OtherNotes
{
get
{
return _othernotes;
}
set
{
_othernotes = value;
}
}
public double ReorderTrigger
{
get
{
return _reordertrigger;
}
set
{
_reordertrigger = value;
}
}
}//end of class
[/code]
Just a note you can do the shorthand if you're not implementing custom logic.
Open in new window
Do the same for all the others that follow it.