void DrawTable()
{
//List of Columns
List<Customer> collection = new List<Customer>();
Customer customer = new Customer();
customer.Date = DateTime.Now.ToString();
customer.LabelfromPost = "Thomas";
collection.Add(customer);
//Add values to list
List<object> data = new List<object>();
for (int i = 0; i < collection.Count; i++)
{
Object row = new { Date = collection[i].Date, LabelfromPost = collection[i].LabelfromPost };
data.Add(row);
}
//Add list to IEnumerable
IEnumerable<object> tableData = data;
//Assign data source
pdfGrid.DataSource = tableData;}
class Customer
{
private string m_date;
private string m_label;
public string Date
{
get
{
return m_date;
}
set
{
m_date = value;
}
}
public string LabelfromPost
{
get
{
return m_label;
}
set
{
m_label = value;
}
}
}
|
//this line is not working for me syntax...
//Add values to list
foreach (var p in posts)
{
How do I select or reference certain data I want to print? |
We can select or refer particular row of data from table (with SQLiteConnection), which wants to print in PDF by using the below query.
But while adding values to list, we can only select the certain data using for loop. | |||
how to reference data from my mysql called post in the foreach loop?
//this line is not working for me syntax...
//Add values to list
foreach (var p in posts)
{
Post row = new {Date = p.CDateTime, p.drain1Lbl = p.drain1vol };
Post.Add(row);
} |
Please add values to the object of the Post class variables before performing the loop. Please refer the below code snippet for your reference,
Or else you can get the whole data source from SQL by using the below query,
You can also get list of data using below code,
Please try the above solution in your end and let us know if it solves the issue.
|
//Assign data source pdfGrid.DataSource = connection.Table | .SQLIteException has been thrown - no such table: Post | I like to use this query to achieve what i needed to do but it's throwing an exception |