A DIV or a Panel are just container controls. Therefore, they have no
DataSource or DataSourceID properties. However, they do expose a
DataBind() method which is there to recursively invoke the DataBind
methods of the contained controls.

Unless you set the DataSource of a control, a Databinding expression
is useless and will not be evaluated. This is the reason why your code
doesn't work.

What you need to do is to set the style property of your DIV or the
BackImageUrl property of your panel in the code.

On Jan 8, 11:36 pm, MrCyber <[email protected]> wrote:
> Ok, after yesterday's problem I have a new one that I can't seem to
> figure out.
>
> I have a SqlDataSource on my page which pulls in the TeamBackground
> field among others. I want to use the data in this field (a filename)
> to set the background of a <DIV> based on this information.
>
> I tried:
> <div id="DisplayTeamData" runat="server" style='background-image: url
> (Graphics/Background/<%#Eval("TeamBackground")%>)'>
> Bunch of text here
> </div>
>
> but that doesn't work as it literally puts "Graphics/Background/<%Eval
> ("TeamBackground")%>" as the background image.
>
> Anyone any idea on how to solve this?
>
> (I'm using C#, so if this needs to be solved in code behind C# code
> would be appreciated)

Reply via email to