0

Hi,

I am using SqlDataSource in order to bind data to dropdownlist and looking for
a simple way to change text color based on specific value from database.

Any idea if I can manipulate the SqlDataSource to do that?
Is this something that I have to call from code-behind?

This is my controls:

<asp:DropDownList 
        ID="pageSelector" 
        runat="server" 
        AutoPostBack="True"
        DataTextField="p_name"
        DataValueField="pid"
        DataSourceID="SqlDataSource2">
        </asp:DropDownList>

        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:_ConStr1 %>" 
        ProviderName="<%$ ConnectionStrings:_ConStr1.ProviderName %>" 
        SelectCommand="SELECT [pid], [p_name], [p_active] FROM [pages] ORDER BY [pid]">
        </asp:SqlDataSource>

And I need something like that:

If DataReader("p_active") = "Yes" Then
   pageSelector.Items(DataReader("pid")).Attributes.Add("style", "color:Green")
Else
   pageSelector.Items(DataReader("pid")).Attributes.Add("style", "color:Red")
End If

Appriciate your help..

Thanks,
YP

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by ypdev
0

I saw that article but it does not reflect my environment..

Any other ideas?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.