Skin ControlStyle of templated fields in DetailsView

Discussion in 'ASP .Net' started by SAL, Apr 13, 2010.

  1. SAL

    SAL Guest

    I've googled this but come up empty.
    Is it possible to declaritively define the ControlStyle for a DetailsView?

    I have a DetailsView skin but when I try this:
    <ControlStyle Font-Size=""9pt" />

    in my skin, I get the error that ControlStyle is not supported. Am I just
    doing it wrong or is this not possible.
    If I template every field in my detailsview, it's a pain to have to set the
    font size for each field. It seems like I should be able to get it done with
    a skin or something.

    Here's the skin:
    <asp:DetailsView runat="server" CssClass="DataWebControlStyle">
    <AlternatingRowStyle CssClass="AlternatingRowStyle" />
    <RowStyle CssClass="RowStyle" />
    <HeaderStyle CssClass="HeaderStyle" />
    </asp:DetailsView>

    Thanks in advance
    S
     
    SAL, Apr 13, 2010
    #1
    1. Advertising

  2. SAL

    Andy O'Neill Guest

    "SAL" <> wrote in message
    news:...
    > I've googled this but come up empty.
    > Is it possible to declaritively define the ControlStyle for a DetailsView?
    >
    > I have a DetailsView skin but when I try this:
    > <ControlStyle Font-Size=""9pt" />
    >
    > in my skin, I get the error that ControlStyle is not supported. Am I just
    > doing it wrong or is this not possible.
    > If I template every field in my detailsview, it's a pain to have to set
    > the font size for each field. It seems like I should be able to get it
    > done with a skin or something.
    >
    > Here's the skin:
    > <asp:DetailsView runat="server" CssClass="DataWebControlStyle">
    > <AlternatingRowStyle CssClass="AlternatingRowStyle" />
    > <RowStyle CssClass="RowStyle" />
    > <HeaderStyle CssClass="HeaderStyle" />
    > </asp:DetailsView>
    >
    > Thanks in advance
    > S

    You can use inline styles something like:

    <asp:DetailsView style="font-size:9pt">
     
    Andy O'Neill, Apr 14, 2010
    #2
    1. Advertising

  3. SAL

    SAL Guest

    Hmmm, for some reason, it seems to render differently for a label and a
    linkbutton.

    For instance, I had already set the value inline as you suggest to a 10pt
    font. However, the linkbutton's text would render a smaller than the label
    server control's text. The font family looks the same however.
    For the page of concern here, there are several DetailsViews on the page. In
    each DetailsView, there are either label controls or linkbuttons depending
    on whether the information leads to another page. So, I'm not sure why they
    render differently.
    It would be nice to get them all to render the same without having to set
    each field's controlStyle's font size property.


    S

    "Andy O'Neill" <> wrote in message
    news:qWjxn.10$2...
    >
    > "SAL" <> wrote in message
    > news:...
    >> I've googled this but come up empty.
    >> Is it possible to declaritively define the ControlStyle for a
    >> DetailsView?
    >>
    >> I have a DetailsView skin but when I try this:
    >> <ControlStyle Font-Size=""9pt" />
    >>
    >> in my skin, I get the error that ControlStyle is not supported. Am I just
    >> doing it wrong or is this not possible.
    >> If I template every field in my detailsview, it's a pain to have to set
    >> the font size for each field. It seems like I should be able to get it
    >> done with a skin or something.
    >>
    >> Here's the skin:
    >> <asp:DetailsView runat="server" CssClass="DataWebControlStyle">
    >> <AlternatingRowStyle CssClass="AlternatingRowStyle" />
    >> <RowStyle CssClass="RowStyle" />
    >> <HeaderStyle CssClass="HeaderStyle" />
    >> </asp:DetailsView>
    >>
    >> Thanks in advance
    >> S

    > You can use inline styles something like:
    >
    > <asp:DetailsView style="font-size:9pt">
     
    SAL, Apr 14, 2010
    #3
  4. Hi SAL,

    Based on my understanding, you need to apply a ControlStyle to the whole
    DetailsView without setting the ControlStyle again and again to each Field
    in it.

    As the DetailsView doesn't support such a global style setting, I suggest
    that we can write code in its Pre_Render event handler to define the
    ControlStyle to each Field via a foreach loop to achieve this task.

    protected void DetailsView1_PreRender(object sender, EventArgs e)
    {
    foreach (DataControlField f in DetailsView1.Fields)
    {
    f.ControlStyle.Font.Size=new FontUnit("9 pt");
    f.ControlStyle.ForeColor = Color.Red;
    //f.ControlStyle.CssClass = "ClassName";
    }
    }

    --
    Sincerely,

    Zhi-Qiang Ni

    Microsoft Online Support
     
    Zhi-Qiang Ni[MSFT], Apr 19, 2010
    #4
  5. Hi SAL,

    This is Zhi-Qiang Ni from MSDN Managed Newsgroup support team, since I
    haven't seen your reply after I last posted my reply, I'm writing to check
    the status of this post. Please feel free to let me know if there's
    anything else I can help.

    Based on my understanding, you need to apply a ControlStyle to the whole
    DetailsView without setting the ControlStyle again and again to each Field
    in it.

    As the DetailsView doesn't support such a global style setting, I suggest
    that we can write code in its Pre_Render event handler to define the
    ControlStyle to each Field via a foreach loop to achieve this task.

    protected void DetailsView1_PreRender(object sender, EventArgs e)
    {
    foreach (DataControlField f in DetailsView1.Fields)
    {
    f.ControlStyle.Font.Size=new FontUnit("9 pt");
    f.ControlStyle.ForeColor = Color.Red;
    //f.ControlStyle.CssClass = "ClassName";
    }
    }

    --
    Sincerely,

    Zhi-Qiang Ni

    Microsoft Online Support
    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    MSDN Managed Newsgroup support offering is for non-urgent issues where an
    initial response from the community or a Microsoft Support Engineer within
    2 business day is acceptable. Please note that each follow up response may
    take approximately 2 business days as the support professional working with
    you may need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations that require urgent,
    real-time or phone-based interactions. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
     
    Zhi-Qiang Ni[MSFT], Apr 23, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RA Scheltema
    Replies:
    3
    Views:
    424
    RA Scheltema
    Jan 6, 2004
  2. Marijn
    Replies:
    5
    Views:
    490
    Marijn
    Feb 13, 2004
  3. Replies:
    0
    Views:
    2,283
  4. Ken Baltrinic

    How to render ControlStyle and other standard attributes?

    Ken Baltrinic, Jan 19, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    457
    Teemu Keiski
    Jan 19, 2006
  5. Sky
    Replies:
    0
    Views:
    296
Loading...

Share This Page