Need help displaying images dynamically in a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm familiar with the Data Controls, however what I have is a website where
users can upload multiple pictures.

I want to display these pictures in a table, that has 3 columns in each row,
and for instance if a user has 3 pictures, one row of three pictures will
display, or if they have 5 pictures, 2 rows, the first with 3 pics and the
second with 2 pics will be rendered.

How can I do something like this?

Thanks for the help in advance,
tperri
 
Hi tperri,

You can save urls of pictures in a datatable:

int N = number of pictures;
int numRows;
int numCols;
int numLastLine = N % 3;
if (numLastLine == 0)
{
numRows = N / 3;
numRows = 3;
}
else
{
numRows = (int)N / 3 + 1;
}
DataRow row;
for (int I = 0; I < numRows; I++)
{
row = pictureTable.NewRow;
if (I == numRows)
{
numCols = numLastLine;
}
else
{
numCols = 3;
}
for (int J = 0; J < numCols; J++)
{
row[J] = pictureUrl[3 * I + J];
}
imageTable.Rows.Add(row);
}

Then use datagrid (data source as above datatable) to show pictures.

HTH

Elton Wang
(e-mail address removed)
 
Thank you very much. I know the basics of the controls, but am just learning
how to use them outside of a textbook learning experience. Your help is much
appreciated.

Elton W said:
Hi tperri,

You can save urls of pictures in a datatable:

int N = number of pictures;
int numRows;
int numCols;
int numLastLine = N % 3;
if (numLastLine == 0)
{
numRows = N / 3;
numRows = 3;
}
else
{
numRows = (int)N / 3 + 1;
}
DataRow row;
for (int I = 0; I < numRows; I++)
{
row = pictureTable.NewRow;
if (I == numRows)
{
numCols = numLastLine;
}
else
{
numCols = 3;
}
for (int J = 0; J < numCols; J++)
{
row[J] = pictureUrl[3 * I + J];
}
imageTable.Rows.Add(row);
}

Then use datagrid (data source as above datatable) to show pictures.

HTH

Elton Wang
(e-mail address removed)


tperri said:
I'm familiar with the Data Controls, however what I have is a website where
users can upload multiple pictures.

I want to display these pictures in a table, that has 3 columns in each row,
and for instance if a user has 3 pictures, one row of three pictures will
display, or if they have 5 pictures, 2 rows, the first with 3 pics and the
second with 2 pics will be rendered.

How can I do something like this?

Thanks for the help in advance,
tperri
 
Back
Top