I am trying to create a thumbnail for an image and display that thumbnail in a DataGrid. I did something similar before but this code is a bit different and I am getting this error on the foreach:
Error 2185 foreach statement cannot operate on variables of type 'System.Data.DataSet' because 'System.Data.DataSet' does not contain a public definition for 'GetEnumerator'
protected void LoadVehicle(string Reg)
{
if (Request.QueryString["type"] == "vehicle")
{
int vehCount = 1;
DataSet veh = DataUtils.GetVehicleFromReg(Company.Current.CompanyID, Reg);
foreach (Vehicle vehicle in veh)
{
tabsPOD.Controls.Add(GetDivVehicle(vehCount, vehicle));
vehCount++;
}
}
}
I was trying to copy this similar code:
protected void LoadDockets(int JobID)
{
if (Request.QueryString["type"] == "dbrief")
{
int DbriefCount = 1;
List<JobPieceSerialNo> Serials = JobPieceSerialNo.GetJobPieceSerialsByJob(JobID);
foreach (JobPieceSerialNo serNo in Serials)
{
tabsPOD.Controls.Add(GetDivDbrief(DbriefCount, serNo));
DbriefCount++;
}
}
}
The problem is GetVehicleFromReg is saved in a file called DataUtilies but then all the properties for the vehicles is saved in a class file called Vehicles.
The problem is, that dataset represents whole data, with tables and rows. You could not iterate it. You could iterate all tables:
foreach(DataTable table in dataSet.Tables)
and than even all rows in the table:
foreach(DataRow row in table.Rows)
If i could assume that you do have only one table in your dataset, so you could write something like:
foreach(DataRow row in veh.Tables[0].Rows)
but id depens on what exact data structure your dataset has.
A DataSet is a container of Tables. So you can enumerate myDataSet.Tables
. This is a DataTableCollection
.
See also MSDN: https://msdn.microsoft.com/en-us/library/system.data.dataset.tables(v=vs.110).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With