E
Eddie B.
I can't seem to find out why i get "Object reference not set to an instance
of an object" error when I put a loop to test what DataTable columns are
present and the loop says that the col is present in the data table that I
am using.
DataTable dtClass = new DataTable();
dtClass = nmopl.GetDrugByClass_PL("");
dsMeds.Tables.Add(dtClass);
DataView dv = new DataView();
dv.Table = dtClass;
this.dgNewMedOrders.DataSource = dtClass;
foreach(DataColumn col in cols)
{
if(col.ColumnName == "ID")
{
MessageBox.Show(col.ColumnName + " Exists");
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "dtClass";
this.dgNewMedOrders.TableStyles.Clear();
dgNewMedOrders.TableStyles.Add(dgts);
dgNewMedOrders.TableStyles["dtClass"].GridColumnStyles["ID"].Width =
10; <---------PROBLEM HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
else
{
MessageBox.Show(col.ColumnName + " is the present column");
}
}
of an object" error when I put a loop to test what DataTable columns are
present and the loop says that the col is present in the data table that I
am using.
DataTable dtClass = new DataTable();
dtClass = nmopl.GetDrugByClass_PL("");
dsMeds.Tables.Add(dtClass);
DataView dv = new DataView();
dv.Table = dtClass;
this.dgNewMedOrders.DataSource = dtClass;
foreach(DataColumn col in cols)
{
if(col.ColumnName == "ID")
{
MessageBox.Show(col.ColumnName + " Exists");
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "dtClass";
this.dgNewMedOrders.TableStyles.Clear();
dgNewMedOrders.TableStyles.Add(dgts);
dgNewMedOrders.TableStyles["dtClass"].GridColumnStyles["ID"].Width =
10; <---------PROBLEM HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
else
{
MessageBox.Show(col.ColumnName + " is the present column");
}
}