Hi everybody,
I am trying to add two table to a page which is part of project. My two tables are putting images to the document. side by side (3 on each side total 6 on a page). when i have picture in both table while creating a new page after checking for overflow ( e.g 8) which will be 1 in each table it work fine but if i have 7 picture it mean i have null in 2nd table than it gave me error
"Object reference not set to an instance of an object "
I am using the following code
Page imagePage = CreatePage();
DataView dataViewImages = new DataView(dataSet.Tables["Images"]);
Table imageLeftTable = new Table(55, 100, 0, 0);
Table imageRightTable = new Table(325, 100, 0, 0);
Table imageTable = new Table(55, 100, 0, 0);
SetupImageTableTest(ref imageTable);
imageTable.Columns.Add(240); //
imageTable.Columns.Add(240); //
SetupImageTable(ref imageLeftTable);
SetupImageTable(ref imageRightTable);
imageLeftTable.Columns.Add(240); //
imageRightTable.Columns.Add(240); //
int control = 0;
foreach (DataRowView dataRowImageView in dataViewImages)
{
if ((control % 2) == 0)
{
CreateCheckInImageTableRow(ref imageLeftTable, dataRowImageView.Row);
control++;
}
else if ((control % 2) == 1)
{
CreateCheckInImageTableRow(ref imageRightTable, dataRowImageView.Row);
control++;
}
}
do
{
AddImageElementToDocument(imageLeftTable, imageRightTable, "Pictures ", " "); // add to document
imageLeftTable = imageLeftTable.GetOverflowRows();
imageRightTable = imageRightTable.GetOverflowRows();
if (imageLeftTable != null)
SetupImageTable(ref imageLeftTable);
if (imageRightTable != null)
SetupImageTable(ref imageRightTable);
} while (imageLeftTable != null || imageRightTable != null);
following are the functions that are called with in the above function.
private void AddImageElementToDocument(PageElement leftTable, PageElement rightTable, string title, string subtitle)
{
Page page = CreatePage();
page.Elements.Add(new TextArea(_description, 32, 14, 350, 50, _fontFamily.Italic, 8));
AddTitleToPage(ref page, title, subtitle);
if (leftTable != null)
page.Elements.Add(leftTable);
if (rightTable != null)
page.Elements.Add(rightTable);
_document.Pages.Add(page);
}
I tried some alternative way but could not solved the problem. can any body help me that what i am doing wrong.
Kind regards
Arbab
Table overflow error
Re: Table overflow error
Forum member · Feb 7, 2012I had done it with one table but still could not figure out whats wrong in original code.
thanks
Re: Table overflow error
Support · Feb 7, 2012Hello Arbab,
Good to know that you were able to resolve the issue by using one table. Your original code is missing some methods (SetupImageTable, CreateCheckInImageTableRow). If you would like us to look into your original code and see why it is not working, please send us the complete code and the line number on which you are getting the error and the complete stack trace of the error to [^a|mailto:support@cete.com|opennewwindow|support@cete.com^].
Thanks,
ceTe Software Support Team.