Saying you have done research does not qualify as "demonstrating" your
research. You should show us what you have tried, what hurdles you
encountered and what errors you faced. I say this because all your
replies in this thread seem to say one thing - "If you cannot show me
the exact code, your answers are useless to me. No psedocode
please !!". I do not believe that to be a very good attitude. Perhaps
others will concur with my analysis.

As I already explained in my previous post, the Panel control does not
have a DataSource property. This means that you cannot DataBind() it
directly to your SqlDatasource. You should therefore conclude that you
require a manual way to select the data from the backend, using the
SqlDataSource. The Select() method of the SqlDataSource provides you
with that functionality. This should have been the direction of your
investigations/research.

Anyway, the answer you want might be as simple as :

---
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
  Try
    Dim iEnum As IEnumerable = myDataSource.Select(New
DataSourceSelectArguments())
    Dim dv As DataView = CType(iEnum, DataView)
    If dv IsNot Nothing AndAlso dv.Count() > 0 Then
      'Get the value in the first record only.
      pnlDisplayTeamData.BackImageUrl = String.Format("Graphics/
Background/{0}", dv.Item(0).Item("DisplayTeamData"))
    End If
  Catch ex As InvalidCastException
      'Confirm that the DataSourceMode property of the SqlDataSource
is set to DataSet.
  Catch ex As Exception
      'Log the error
  End Try
End Sub
---

On Jan 10, 8:36 pm, MrCyber <[email protected]> wrote:
> and how would I do that. This is the problem. I've searched the
> internet for hours and hours trying to figure it out, but still
> haven't found a solution.
>
> On Jan 9, 1:42 am, Cerebrus <[email protected]> wrote:
>
>
>
> > 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)- Hide quoted text -
>
> - Show quoted text -

Reply via email to