Need help displaying images dynamically in a table

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
 
G

Guest

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)
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top