Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > datalist background image for each cell

Reply
Thread Tools

datalist background image for each cell

 
 
phil2phil
Guest
Posts: n/a
 
      12-04-2006
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.

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12-04-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.
>



 
Reply With Quote
 
 
 
 
phil2phil
Guest
Posts: n/a
 
      12-04-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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.
> >


 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12-04-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) 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.
> > >

>



 
Reply With Quote
 
phil2phil
Guest
Posts: n/a
 
      12-04-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) 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.
> > > >

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform a 2D color image into 2 images of (R1,G1,B) at each pixelof image 1 and (R2,G2,B) at each pixel of image2 for STEREO visualization 88888 Dihedral C++ 10 12-23-2011 02:28 PM
how do i? Full scan of each control in each grid row cell John Blair ASP .Net 1 08-03-2005 11:02 AM
How to set cell background based on cell value when datagrid is displayed RJ ASP .Net Datagrid Control 1 02-17-2005 09:37 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
way to set background image static and it doesnt load after each postback? Bogosian ASP .Net 4 01-07-2004 03:54 PM



Advertisments