yuma md
yuma md

Reputation: 51

ASP ListView Multiple Style

I'm having trouble with asp ListView. I have [Message] Table which include status field = read or unread,

can listview provide different style to show this different such as,

if(Message.Status == "unread")
    {
       div background color = "yellow"
    }
else if (Message.Status == "read")
    {
       div background color = "Grey"
    }

Is this possible?

Thanks in Advance.

Upvotes: 1

Views: 289

Answers (2)

yuma md
yuma md

Reputation: 51

i found somewhere in this site.. but forgot to bookmark it..

protected void ListInbox_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        Panel PanelMsg;
        PanelMsg = (Panel)e.Item.FindControl("PanelMsg");

        ListViewDataItem dataItem = (ListViewDataItem)e.Item;
        string status = (string)DataBinder.Eval(dataItem.DataItem, "Status");
        if (status == "unread")
        {
            PanelMsg.BackColor = System.Drawing.Color.Purple;
        }
    }

thanks to DJ Kraze for the support..

Upvotes: 1

MethodMan
MethodMan

Reputation: 18863

listview tips and tricks

Take a look at his site

Upvotes: 2

Related Questions