format repeater row

S

Scott

Is there a way to format a row within a repeater based on the data? If I
have my row (cell 0) text is "Used" I want that entire row to have a blue
background color. Is it possible to do that in the repeater?
 
E

Eliyahu Goldin

Sure. Handle the ItemDataBound event to set visual properties or, better,
the css class for the html control representing the row. To locate that
control in the repeater item, set the control id and runat="server" and call
e.Item.FindControl(myRowId).

It comes to something like this:
<ItemTemplate>
<div runat="server" id="myRowId">
....
</div>
</ItemTemplate>

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
S

Scott

I've tried that and its not picking up the formatting that I need.
example:
if my lable in the repeater equals, 'Used' the background for that row or
cell isn't changing colors or the font for that label is changing to a bold.



Eliyahu Goldin said:
Sure. Handle the ItemDataBound event to set visual properties or, better,
the css class for the html control representing the row. To locate that
control in the repeater item, set the control id and runat="server" and
call e.Item.FindControl(myRowId).

It comes to something like this:
<ItemTemplate>
<div runat="server" id="myRowId">
...
</div>
</ItemTemplate>

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Scott said:
Is there a way to format a row within a repeater based on the data? If I
have my row (cell 0) text is "Used" I want that entire row to have a blue
background color. Is it possible to do that in the repeater?
 
E

Eliyahu Goldin

This simply means that your code doesn't do what you need. Debug it.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Scott said:
I've tried that and its not picking up the formatting that I need.
example:
if my lable in the repeater equals, 'Used' the background for that row or
cell isn't changing colors or the font for that label is changing to a
bold.



Eliyahu Goldin said:
Sure. Handle the ItemDataBound event to set visual properties or, better,
the css class for the html control representing the row. To locate that
control in the repeater item, set the control id and runat="server" and
call e.Item.FindControl(myRowId).

It comes to something like this:
<ItemTemplate>
<div runat="server" id="myRowId">
...
</div>
</ItemTemplate>

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Scott said:
Is there a way to format a row within a repeater based on the data? If I
have my row (cell 0) text is "Used" I want that entire row to have a
blue background color. Is it possible to do that in the repeater?
 

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

Top