Home All Groups Group Topic Archive Search About

GridView Edit Template Control Style

Author
10 Feb 2009 8:29 PM
Morris Neuman
Hi,
I have a gridview and have set the font size to 8pt and forecolor to navy.

When I set the editrowstyle to different values it works for labels in edit
template mode, but not for textboxes, dropdownlist or other controls.  Do I
have to set the style for each control individually?  I only want the
different style to affect the controls in edit template mode.
--
Thanks
Morris

Author
11 Feb 2009 2:37 AM
Allen Chen [MSFT]
Hi Morris,

To do this you can set CssClass for the EditRowStyle.

CSS:

<style type="text/css">
    .test input{ background-color:Red;}
    .test select { background-color:Green;}
</style>


aspx:

<asp:GridView ...
<EditRowStyle CssClass="test" />
...

ASP.NET TextBox control renders <input> to the client side. ASP.NET
DropDownList control renders <select> to the client side. So the above
styles will apply to the elements rendered by them. You can view source of
the page to see what HTML tags are rendered by ASP.NET controls to see how
to set correct CSS for them.

Please have a try and let me know if it works.

Regards,
Allen Chen
Microsoft Online Support
Author
13 Feb 2009 1:38 AM
Allen Chen [MSFT]
Hi Morris,

Can my code work?

Regards,
Allen Chen
Microsoft Online Support
Author
17 Feb 2009 4:29 AM
Morris Neuman
How do I create a CssClass page?
--
Thanks
Morris


Show quoteHide quote
"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> Can my code work?
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
>
Author
17 Feb 2009 5:59 AM
Allen Chen [MSFT]
Hi Morris,

To use CSS on your page you have two options in general.

"    Inline style sheet:
http://www.w3schools.com/Css/tryit.asp?filename=trycss_background-color

"    External style sheet:
http://www.w3schools.com/Css/showit.asp?filename=ex1

You can learn CSS from:
http://www.w3schools.com/Css/default.asp

Other reference:
http://msdn.microsoft.com/en-us/library/h4kete56.aspx

If you have additional questions please feel free to ask.

Regards,
Allen Chen
Microsoft Online Support
Author
19 Feb 2009 7:27 AM
Allen Chen [MSFT]
Hi Morris,

Have you solved this issue?

Regards,
Allen Chen
Microsoft Online Community Support