Cannot dynamically assign a BackColor to a datalist

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • .Net Sports

    Cannot dynamically assign a BackColor to a datalist

    I need to dynamically assign a datalist attribute upon a helper
    function receiving data from a querystring. If a user picks a certain
    region, i need the datalist to display its back color, or any of its
    other objects , as a certain color or css style



    <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>

    ....doesnot work as a Parser error renders: Content ('<HeaderStyle
    BackColor=') does not match any properties within a
    'System.Web.UI. WebControls.Dat aList', make sure it is well-formed



  • Mark Fitzpatrick

    #2
    Re: Cannot dynamically assign a BackColor to a datalist

    Do it programatically . You can access the property directly from code as
    follows:
    assume the name of the datalist is dl

    dl.HeaderStyle. BackColor = Color.Red;

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - Expression

    ".Net Sports" <ballz2wall@cox .netwrote in message
    news:1e75f9e9-a7b7-474d-9f12-21c4ba993277@i3 6g2000prf.googl egroups.com...
    >I need to dynamically assign a datalist attribute upon a helper
    function receiving data from a querystring. If a user picks a certain
    region, i need the datalist to display its back color, or any of its
    other objects , as a certain color or css style
    >
    >
    >
    <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
    >
    ...doesnot work as a Parser error renders: Content ('<HeaderStyle
    BackColor=') does not match any properties within a
    'System.Web.UI. WebControls.Dat aList', make sure it is well-formed
    >
    >
    >

    Comment

    • .Net Sports

      #3
      Re: Cannot dynamically assign a BackColor to a datalist

      Thanks for your response. There is no code behind in these scripts/
      programs I am using. Inside the Datalist form block, I have:

      <asp:DataList id="dlstCats" runat="server" RepeatColumns=" 4"
      width="350px" ItemStyle-BackColor="#ccf fcc" cellspacing="3" >

      <HeaderStyle BackColor="#008 000"</HeaderStyle>
      <HeaderTemplate <font class="body11-
      wh">Providers for
      <%= sregionZ %>: <%= Zonecustom() %></font</
      HeaderTemplate>
      <ItemTemplate>< font class="body9bol d-re"<a
      href="re.aspx?z one=<%#Server.U rlEncode(Reques t.QueryString(" zone")) &
      "&amp;cregi on=" & Server.UrlEncod e(Request.Query String("cregion ")) &
      "&amp;category= " & (Eval("Category ").ToString())% >">
      <%# Eval("Category" )%>
      </a></font></ItemTemplate>
      </asp:DataList>

      as you see, I can provide dynamic variables from helper functions in
      the headers of my page to stuff inside the Header Template & the
      ItemTemplate, but I need to dynamically also change the HeaderStyle
      BackColor property here


      TIA
      ..netsports

      On Apr 16, 5:39 pm, "Mark Fitzpatrick" <markf...@fitzm e.comwrote:
      Do it programatically . You can access the property directly from code as
      follows:
      assume the name of the datalist is dl
      >
      dl.HeaderStyle. BackColor = Color.Red;
      >
      Hope this helps,
      Mark Fitzpatrick
      Microsoft MVP - Expression
      >
      ".Net Sports" <ballz2w...@cox .netwrote in message
      >
      news:1e75f9e9-a7b7-474d-9f12-21c4ba993277@i3 6g2000prf.googl egroups.com...
      >
      I need to dynamically assign a datalist attribute upon a helper
      function receiving data from a querystring. If a user picks a certain
      region, i need the datalist to display its back color, or any of its
      other objects , as a certain color or css style
      >
      <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
      >
      ...doesnot work as a Parser error renders: Content ('<HeaderStyle
      BackColor=') does not match any properties within a
      'System.Web.UI. WebControls.Dat aList', make sure it is well-formed

      Comment

      • wisccal@googlemail.com

        #4
        Re: Cannot dynamically assign a BackColor to a datalist

        Hi,

        I suggest you wrap your HeaderTemplate content in a div and
        dynamically assign a style to that element. Something like:

        <HeaderTemplate >
        <div style='backgrou nd-color:<%= ssponcont %>' >
        <font class="body11-wh">Providers for <%= sregionZ %>: <%=
        Zonecustom() %></font>
        <div>
        </HeaderTemplate>

        ============
        Regards,
        Steve


        ..Net Sports wrote:
        Thanks for your response. There is no code behind in these scripts/
        programs I am using. Inside the Datalist form block, I have:
        >
        <asp:DataList id="dlstCats" runat="server" RepeatColumns=" 4"
        width="350px" ItemStyle-BackColor="#ccf fcc" cellspacing="3" >
        >
        <HeaderStyle BackColor="#008 000"</HeaderStyle>
        <HeaderTemplate <font class="body11-
        wh">Providers for
        <%= sregionZ %>: <%= Zonecustom() %></font</
        HeaderTemplate>
        <ItemTemplate>< font class="body9bol d-re"<a
        href="re.aspx?z one=<%#Server.U rlEncode(Reques t.QueryString(" zone")) &
        "&amp;cregi on=" & Server.UrlEncod e(Request.Query String("cregion ")) &
        "&amp;category= " & (Eval("Category ").ToString())% >">
        <%# Eval("Category" )%>
        </a></font></ItemTemplate>
        </asp:DataList>
        >
        as you see, I can provide dynamic variables from helper functions in
        the headers of my page to stuff inside the Header Template & the
        ItemTemplate, but I need to dynamically also change the HeaderStyle
        BackColor property here
        >
        >
        TIA
        .netsports
        >
        On Apr 16, 5:39 pm, "Mark Fitzpatrick" <markf...@fitzm e.comwrote:
        Do it programatically . You can access the property directly from code as
        follows:
        assume the name of the datalist is dl

        dl.HeaderStyle. BackColor = Color.Red;

        Hope this helps,
        Mark Fitzpatrick
        Microsoft MVP - Expression

        ".Net Sports" <ballz2w...@cox .netwrote in message

        news:1e75f9e9-a7b7-474d-9f12-21c4ba993277@i3 6g2000prf.googl egroups.com...
        >I need to dynamically assign a datalist attribute upon a helper
        function receiving data from a querystring. If a user picks a certain
        region, i need the datalist to display its back color, or any of its
        other objects , as a certain color or css style
        <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
        ...doesnot work as a Parser error renders: Content ('<HeaderStyle
        BackColor=') does not match any properties within a
        'System.Web.UI. WebControls.Dat aList', make sure it is well-formed

        Comment

        • wisccal@googlemail.com

          #5
          Re: Cannot dynamically assign a BackColor to a datalist

          Hi,

          I suggest you wrap your HeaderTemplate content in a div and
          dynamically assign a style to that element. Something like:

          <HeaderTemplate >
          <div style='backgrou nd-color:<%= ssponcont %>' >
          <font class="body11-wh">Providers for <%= sregionZ %>: <%=
          Zonecustom() %></font>
          <div>
          </HeaderTemplate>

          ============
          Regards,
          Steve


          ..Net Sports wrote:
          Thanks for your response. There is no code behind in these scripts/
          programs I am using. Inside the Datalist form block, I have:
          >
          <asp:DataList id="dlstCats" runat="server" RepeatColumns=" 4"
          width="350px" ItemStyle-BackColor="#ccf fcc" cellspacing="3" >
          >
          <HeaderStyle BackColor="#008 000"</HeaderStyle>
          <HeaderTemplate <font class="body11-
          wh">Providers for
          <%= sregionZ %>: <%= Zonecustom() %></font</
          HeaderTemplate>
          <ItemTemplate>< font class="body9bol d-re"<a
          href="re.aspx?z one=<%#Server.U rlEncode(Reques t.QueryString(" zone")) &
          "&amp;cregi on=" & Server.UrlEncod e(Request.Query String("cregion ")) &
          "&amp;category= " & (Eval("Category ").ToString())% >">
          <%# Eval("Category" )%>
          </a></font></ItemTemplate>
          </asp:DataList>
          >
          as you see, I can provide dynamic variables from helper functions in
          the headers of my page to stuff inside the Header Template & the
          ItemTemplate, but I need to dynamically also change the HeaderStyle
          BackColor property here
          >
          >
          TIA
          .netsports
          >
          On Apr 16, 5:39 pm, "Mark Fitzpatrick" <markf...@fitzm e.comwrote:
          Do it programatically . You can access the property directly from code as
          follows:
          assume the name of the datalist is dl

          dl.HeaderStyle. BackColor = Color.Red;

          Hope this helps,
          Mark Fitzpatrick
          Microsoft MVP - Expression

          ".Net Sports" <ballz2w...@cox .netwrote in message

          news:1e75f9e9-a7b7-474d-9f12-21c4ba993277@i3 6g2000prf.googl egroups.com...
          >I need to dynamically assign a datalist attribute upon a helper
          function receiving data from a querystring. If a user picks a certain
          region, i need the datalist to display its back color, or any of its
          other objects , as a certain color or css style
          <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
          ...doesnot work as a Parser error renders: Content ('<HeaderStyle
          BackColor=') does not match any properties within a
          'System.Web.UI. WebControls.Dat aList', make sure it is well-formed

          Comment

          Working...