Skin ControlStyle of templated fields in DetailsView

  • Thread starter Thread starter SAL
  • Start date Start date
S

SAL

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 said:
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">
 
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
 
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
 
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
==================================================
 
Back
Top