This code applies the style to the itemStyle of the whole list, so
unless the last item in the list statisifies the rule, your item style
will be unchanged.
Also it appears you have set the CssClass of each label explicitly,
which means that updating the style for the list will have no effect.
In either case, it appears you want to apply the style on an
item-by-item basis. You probably want to hook your list up to call
OnItemDataBound and set the style for each given item as it is bound.
You can also use this to access each individual label in the item,
which is probably what you need to do.
On 6/20/05, kstrader2002 <[EMAIL PROTECTED]> wrote:
> I need to format each "row" of my datalist based on a certain
> criteria. I'm not sure if it's the fact that the items of the
> datalist are within a table that I'm having problems getting the
> formatting to work or if it's the syntax that I'm using:
>
> Here's the aspx:
>
> <TD vAlign="top" width="70%" height="115"><asp:datalist
> id="dlstActivity" runat="server" Width="752px">
> <HeaderTemplate>
> <TABLE
> height="25" width="100%">
> <TR>
>
> <TD align="left" width="70%">
>
> <asp:label id="lblActivityName" runat="server"
> text="Activity Name" CssClass="textbold">Activity
> Name</asp:label></TD>
>
> <TD align="left" width="15%">
>
> <asp:label id="lblActivityHours" runat="server"
> text="Activity Hours" CssClass="textbold">Activity
> Hours</asp:label></TD>
>
> <TD align="right" width="15%">
>
> <asp:label id="lblAssignedHours" runat="server"
> text="Assigned Hours" CssClass="textbold">Assigned
> Hours</asp:label></TD>
> </TR>
> </TABLE>
> </HeaderTemplate>
> <ItemStyle
> HorizontalAlign="Left" Width="450px"></ItemStyle>
> <ItemTemplate>
> <TABLE
> height="25" width="100%">
> <TR>
>
> <TD align="left" width="70%">
>
> <asp:label id=lblActivityName2 runat="server"
> text='<%# Databinder.Eval(Container,"DataItem.ActivityName") %>'
> CssClass="text">
>
> </asp:label></TD>
>
> <TD align="left" width="15%">
>
> <asp:label id=lblActivityHours2 runat="server"
> text='<%# Databinder.Eval(Container,"DataItem.SuppAct_hours") %>'
> CssClass="text">
>
> </asp:label></TD></TD>
> <TD align="right" width="15%">
> <asp:label
> id=lblAssignedHours2 runat="server" text='<%# Databinder.Eval
> (Container,"DataItem.tot_pa_hours") %>' CssClass="text">
> </asp:label></TD>
> </TD>
> </tr>
> </TABLE>
> </ItemTemplate>
> <HeaderStyle HorizontalAlign="Left"
> Width="450px"></HeaderStyle>
>
> From the code-behind page - I want to apply the logic that if
> the "lblAssignedhrs" value is greater than the "lblActivityhrs" then
> I want the text to be red. the below code is producing no change in
> the text.
>
> Try
> Dim dt_PeopleActivity =
> DataHelper.GetPeopleActivitiesAndHours(busID, locID)
> Dim dvw_PeopleActivity = New DataView(dt_PeopleActivity)
> Dim r As DataRowView
> For Each r In dvw_PeopleActivity
> If r("tot_pa_hours") > r("suppact_hours") Then
>
> dlstActivity.ItemStyle.ForeColor = forecolor.red
> End If
> Next
>
> BindActivityDlst(dvw_PeopleActivity)
> Catch ex As Exception
> Throw New Exception("Get People Activity List failed",
> ex)
> End Try
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/