i have problems changing class of css in asp:panel. try lot of tips here me. code of itemtemplate is:
<itemtemplate> <asp:panel class="item" runat="server"> <asp:label id="customernamelabel" runat="server" text='<%# eval("customername") %>' /> <br /> <asp:label id="lastincomelabel" runat="server" text='<%# eval("lastincome") %>' /> <br /> </asp:panel> </itemtemplate> and try this:
protected sub myevent(byval sender object, byval e eventargs) dim dt new date dim dv system.data.dataview dim thepanel htmlgenericcontrol = new htmlgenericcontrol("item") dv = ctype(sqldatasource1.select(datasourceselectarguments.empty), dataview) dim s string s = dv.table.rows.item(0).item(1) lastincome = convert.todatetime(s) if lastincome.addhours(1) < thepanel.attributes.add("style", "background-color:red") 'problem else thepanel.attributes("class") = "itemgreen" 'ok end if end sub i have tried thepanel.attributes.add or thepanel.attributes("class") = "itemgreen" not function on onload="myevent" in listview declaration.
can me? thanks
you set function eval.
<asp:panel cssclass='<%# getcssclass(eval("lastincome")) %>' runat="server"> that way don't need handle event or try figure out element/item use.
the function , logic needed return right css.
function getcssclass(byval lastincome datetime) string i suggest have class called itemred instead of setting color red directly in style attribute.
if want use event, suggest use other 1 load. check itemcreated.
Comments
Post a Comment