By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,587 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,587 IT Pros & Developers. It's quick & easy.

datalist background image for each cell

P: n/a
Hi,
Right now I have a datalist, that renders the following html:

<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Monday</div> </td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Tuesday</div> </td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Wednesday</div> </td>
</tr>

We now need to have each cell use a background image, but they need to
vary, so Monday's background image will not be the same as Tues. The
images sizes will be the same, but the image displayed will vary. Is
there anyway to do this? I can remove the ItemStyle-CssClass="daycss"
property I've set in the datalist, but how do I get it to set a
different image for each cell?

Thanks.

Dec 4 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Prepare css classes for every image. Handle the datalist's PreRender event.
In the event, loop through the datalist items and set the CssClass property
for every item to the required css class depending on the item's day of
week.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"phil2phil" <ph*********@yahoo.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi,
Right now I have a datalist, that renders the following html:

<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Monday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Tuesday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Wednesday</div</td>
</tr>

We now need to have each cell use a background image, but they need to
vary, so Monday's background image will not be the same as Tues. The
images sizes will be the same, but the image displayed will vary. Is
there anyway to do this? I can remove the ItemStyle-CssClass="daycss"
property I've set in the datalist, but how do I get it to set a
different image for each cell?

Thanks.

Dec 4 '06 #2

P: n/a
Hi,
Thanks for the response, could you show me how to loop through the
datalist items and set the CssClass, a quick sample?

Thanks again.

Eliyahu Goldin wrote:
Prepare css classes for every image. Handle the datalist's PreRender event.
In the event, loop through the datalist items and set the CssClass property
for every item to the required css class depending on the item's day of
week.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"phil2phil" <ph*********@yahoo.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi,
Right now I have a datalist, that renders the following html:

<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Monday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Tuesday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Wednesday</div</td>
</tr>

We now need to have each cell use a background image, but they need to
vary, so Monday's background image will not be the same as Tues. The
images sizes will be the same, but the image displayed will vary. Is
there anyway to do this? I can remove the ItemStyle-CssClass="daycss"
property I've set in the datalist, but how do I get it to set a
different image for each cell?

Thanks.
Dec 4 '06 #3

P: n/a
something like

foreach (DataListItem item in myDataList.Items)
{
item.CssClass = getItemClass(item);
}

string getItemClass (DataListItem item)
{
// get the day for the item
...
// get the class for the day
...
}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"phil2phil" <ph*********@yahoo.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
Hi,
Thanks for the response, could you show me how to loop through the
datalist items and set the CssClass, a quick sample?

Thanks again.

Eliyahu Goldin wrote:
Prepare css classes for every image. Handle the datalist's PreRender
event.
In the event, loop through the datalist items and set the CssClass
property
for every item to the required css class depending on the item's day of
week.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"phil2phil" <ph*********@yahoo.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi,
Right now I have a datalist, that renders the following html:
>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Monday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Tuesday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Wednesday</div</td>
</tr>
>
We now need to have each cell use a background image, but they need to
vary, so Monday's background image will not be the same as Tues. The
images sizes will be the same, but the image displayed will vary. Is
there anyway to do this? I can remove the ItemStyle-CssClass="daycss"
property I've set in the datalist, but how do I get it to set a
different image for each cell?
>
Thanks.
>

Dec 4 '06 #4

P: n/a
Thanks again!

Eliyahu Goldin wrote:
something like

foreach (DataListItem item in myDataList.Items)
{
item.CssClass = getItemClass(item);
}

string getItemClass (DataListItem item)
{
// get the day for the item
...
// get the class for the day
...
}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"phil2phil" <ph*********@yahoo.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
Hi,
Thanks for the response, could you show me how to loop through the
datalist items and set the CssClass, a quick sample?

Thanks again.

Eliyahu Goldin wrote:
Prepare css classes for every image. Handle the datalist's PreRender
event.
In the event, loop through the datalist items and set the CssClass
property
for every item to the required css class depending on the item's day of
week.
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
>
>
"phil2phil" <ph*********@yahoo.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi,
Right now I have a datalist, that renders the following html:

<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Monday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Tuesday</div</td>
</tr>
<tr>
<td class="daycss" align="Left" valign="Top"
style="background-color:#EEEEEE;height:20px;">
<div style="PADDING-LEFT:26px;
PADDING-TOP:1px">Wednesday</div</td>
</tr>

We now need to have each cell use a background image, but they need to
vary, so Monday's background image will not be the same as Tues. The
images sizes will be the same, but the image displayed will vary. Is
there anyway to do this? I can remove the ItemStyle-CssClass="daycss"
property I've set in the datalist, but how do I get it to set a
different image for each cell?

Thanks.
Dec 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.