CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: NewsGroup Date Entered: 3/29/2007 5:01:32 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 74 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
Richard Lawley
Asp.Net User
GridView Adapter doesn't distinguish between ItemStyle and HeaderStyle3/29/2007 5:01:32 PM

0/0

I've just converted my application to use the GridView CSS adapter, and I've noticed that it doesn't distinguish between Item styles and header styles when rendering the cells.  Thus if you have a column like this...

<asp:BoundField HeaderText="Monthly" DataField="Monthly" ItemStyle-CssClass="CellRight" />

... it will apply the style "CellRight" to both the item cells and the row header, which is not what I wanted.

I've fixed the GridView Adapter to allow this to work.  I've included my modified WriteRows function below:

 

1            private void WriteRows(HtmlTextWriter writer, GridView gridView, GridViewRowCollection rows, string tableSection) {
2                if (rows.Count > 0) {
3                    writer.WriteLine();
4                    writer.WriteBeginTag(tableSection);
5                    writer.Write(HtmlTextWriter.TagRightChar);
6                    writer.Indent++;
7    
8                    foreach (GridViewRow row in rows) {
9                        writer.WriteLine();
10                       writer.WriteBeginTag("tr");
11   
12                       string className = GetRowClass(gridView, row);
13                       if (!String.IsNullOrEmpty(className)) {
14                           writer.WriteAttribute("class", className);
15                       }
16   
17                       //  Uncomment the following block of code if you want to add arbitrary attributes.
18                       /*
19                       foreach (string key in row.Attributes.Keys)
20                       {
21                           writer.WriteAttribute(key, row.Attributes[key]);
22                       }
23                       */
24   
25                       writer.Write(HtmlTextWriter.TagRightChar);
26                       writer.Indent++;
27   
28                       foreach (TableCell cell in row.Cells) {
29                           DataControlFieldCell fieldCell = cell as DataControlFieldCell;
30                           if ((fieldCell != null) && (fieldCell.ContainingField != null)) {
31                               DataControlField field = fieldCell.ContainingField;
32                               if (!field.Visible) {
33                                   cell.Visible = false;
34                               }
35   
36                               if (row.RowType == DataControlRowType.Header) {
37                                   if ((field.HeaderStyle != null) && (!String.IsNullOrEmpty(field.HeaderStyle.CssClass))) {
38                                       if (!String.IsNullOrEmpty(cell.CssClass)) {
39                                           cell.CssClass += " ";
40                                       }
41                                       cell.CssClass += field.HeaderStyle.CssClass;
42                                   }
43   
44                               } else if (row.RowType == DataControlRowType.DataRow) {
45                                   if ((field.ItemStyle != null) && (!String.IsNullOrEmpty(field.ItemStyle.CssClass))) {
46                                       if (!String.IsNullOrEmpty(cell.CssClass)) {
47                                           cell.CssClass += " ";
48                                       }
49                                       cell.CssClass += field.ItemStyle.CssClass;
50                                   }
51   
52                               } else if (row.RowType == DataControlRowType.Footer) {
53                                   if ((field.FooterStyle != null) && (!String.IsNullOrEmpty(field.FooterStyle.CssClass))) {
54                                       if (!String.IsNullOrEmpty(cell.CssClass)) {
55                                           cell.CssClass += " ";
56                                       }
57                                       cell.CssClass += field.FooterStyle.CssClass;
58                                   }
59   
60                               }
61   
62                           }
63   
64                           writer.WriteLine();
65                           cell.RenderControl(writer);
66                       }
67   
68                       writer.Indent--;
69                       writer.WriteLine();
70                       writer.WriteEndTag("tr");
71                   }
72   
73                   writer.Indent--;
74                   writer.WriteLine();
75                   writer.WriteEndTag(tableSection);
76               }
77           }
  
bdemarzo
Asp.Net User
Re: GridView Adapter doesn't distinguish between ItemStyle and HeaderStyle3/30/2007 2:31:56 PM

0/0

I'm applying this patch, slightly modified.

// Apply item style CSS class
TableItemStyle itemStyle;
switch (row.RowType)
{
	case DataControlRowType.Header:
		itemStyle = field.HeaderStyle;
		break;
	case DataControlRowType.Footer:
		itemStyle = field.FooterStyle;
		break;
	default:
		itemStyle = field.ItemStyle;
		break;
}
if (itemStyle != null && !String.IsNullOrEmpty(itemStyle.CssClass))
{
	if (!String.IsNullOrEmpty(cell.CssClass))
		cell.CssClass += " ";
	cell.CssClass += itemStyle.CssClass;
}

The above patch brings up a question... Should the adapters convert other styles in the itemStyle object, such as Wrap and BorderColor? One argument is that it shouldn't; such style should be applied from CSS classes. However, this does make functionality disappear in ways which may not be "obvious" to the user. Something to think about moving forward...


- brian
- blog: www.sidesofmarch.com
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Build a Shopping Cart in ASP.NET - NETTUTS Nov 18, 2008 ... I won't discuss the style elements because they are .... I also have a CSS control adapter that modifies the output of the GridView class to ...
A Look of the New Services, Controls, and Features in ASP.NET 2.0 NET distinguishes between default skins and non-default skins. ..... Deploying without source doesn't provide ironclad protection of your intellectual ...
The Data Controls However, the GridView doesn’t provide properties, such as DataTextField ..... < ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />. The Data Controls However, the GridView doesn’t provide properties, such as DataTextField and DataValueField, .... ControlStyle, HeaderStyle,. FooterStyle, and ItemStyle ...
Microsoft ASP.NET 2.0 How can the target page distinguish between a page and a cross-page postback? ...... FooterText HeaderImageUrl HeaderStyle HeaderText ItemStyle ShowHeader ...
Telerik.Web.UI Describes an object that can be used to resolve ... ItemStyle Property AlternatingItemStyle Property HeaderStyle Property ...... NoneSupressCleanMessage Doesn't strip anything and does not ask a question. ...
VB Helper: Karen Watterson's Archived Destinations and Diversions ... One that doesn't require a keyboard, mouse, or video graphics adapter (VGA) ...... Server control wraps when the ItemStyle Wrap property or the HeaderStyle ...
Expert One-on-One Visual Basic 2005 Database Programming Contract-based interoperation between the interface provider and its callers. Implementing SOA doesn’t require the use of SOAP-based Web services, ...
September 2008 - .Net Advanced topic I've tried looping through the GridView pages, but it doesn't seem to work, maybe because ...... . ...
Web.config assemblies changing when deploying in VS2005 - ng.asp ... I have no idea why it's doing this, but since we don't actually install the .... gridview adapter doesn't distinguish between itemstyle and headerstyle ...




Search This Site:










creating an image adapter

datalist error

aspnet-menu-withchildren aspnet-menu-childselected

menu control - background images

.vsi broken?

css help for control

i cant make it work

announcement: beta 3 has been released

problem in cached pages (master page?)

staticdisplaylevels on menu no effect?

implementing prettymenu

gridviewadapter and visible flag

menuadapter beta 2

modify menu adapter to show selected <ul> element

browser definition files - restrict to certain folders only

bug in the datalist adapter

issue with menu appearance in ie

compilation error in menuadapter.cs

readme steps for cssfriendly adapters

problem in ie7 with variable width of horizontal top level menu elements

css friendly treeview

moss topnav links in admin pages altered after adapters implemented.

logincontroladapter

commandfield with control style not picked up by css theme

problems with css adaptors and using two menus

bug? login control fires onloggedin and onloginerror twice with css friendly adapters

how to make microsoft filter effect work in mozilla

ie 6 problem - search results are pushed down in the content area

i need build "repeatlayout" support myself?

different output of menuadapter- and sharepoint:aspmenu-control

  Privacy | Contact Us
All Times Are GMT