u can't use IIF()
System.Drawing.Color.FromName(Eval("AttachmentEnti tyForeColor")) will
still be executed, resulting in error
(IIF is not equaivalent to C's '?' command)
u need to write another function
public function BackColor(AColor as Object) as String
if typeof AColor is DBNull then
return "#FFFFFF"
else
return System.Drawing.Color.FromName(AColor)
end if
end function
BackColor='<%#BackColor(eval("AttachmentEntityBack Color"))%>'
On Jun 19, 5:33*am, "Cirene" <cir...@nowhere.com> wrote:
> This doesn't seem to work...
>
> <asp:Label ID="lblSampleColorScheme" runat="server"
>
> BackColor='<%# iif(eval("AttachmentEntityBackColor").equals(DBNul l.value),
> "#ffffff", System.Drawing.Color.FromName(Eval("AttachmentEnti tyBackColor")))
> %>' Font-Bold="True"
>
> ForeColor='<%# iif(eval("AttachmentEntityForeColor").equals(DBNul l.value),
> "#000000", System.Drawing.Color.FromName(Eval("AttachmentEnti tyForeColor")))
> %>' Text="CURRENT COLOR SCHEME"></asp:Label>
>
> "Cirene" <cir...@nowhere.com> wrote in message
>
> news:...
>
> > I'm setting a databound label's backcolor and forecolor like this...
>
> > <asp:Label ID="lblSampleColorScheme" runat="server"
>
> > BackColor='<%#
> > System.Drawing.Color.FromName(Eval("AttachmentEnti tyBackColor")) %>'
> > Font-Bold="True"
>
> > ForeColor='<%#
> > System.Drawing.Color.FromName(Eval("AttachmentEnti tyForeColor")) %>'
> > Text="CURRENT COLOR SCHEME"></asp:Label>
>
> > The problem is when the value is NULL. *I get the above error. *How can I
> > say, if it's null in the db then use "#ffffff"?
>
> > Thanks!
|