Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages by Jacob J. Sanford; ISBN: 9780470124482
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 24th, 2008, 02:22 PM
Registered User
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Customize column in CSS friendly GridView


I'm new to CSS, ASP.NET, and CSS friendly controls, but I feel I'm making progress with the help of Jacob Sanford's book - "Profession ASP.NET 2.0 Design..." (thanks Jacob, if you're here).

I'm currently in chapter 5 ("ASP.NET 2.0 CSS Friendly Control Adapters"). I'm experimenting with a very simple CSS friendly GridView control. Overall it's going well, but I'm wondering how I might single out a single column for non-default alignment. For example, I might want the first column to be center-aligned, while leaving the others at the default left-alignment state.

I tried specifying an ID selector down in the asp:boundfield statement, but of course it didn't like that. What am I missing?

  #2 (permalink)  
Old April 24th, 2008, 03:47 PM
Wrox Author
Join Date: Sep 2006
Location: Tallahassee, FL, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to surfer5 Send a message via AIM to surfer5 Send a message via MSN to surfer5 Send a message via Yahoo to surfer5

Hey Frank-

Let me just say that the chapter you are reading was probably my favorite to write. I continue to preach the merits of the adapters to all that will listen. I am co-authoring another book on SharePoint design and I just finished writing the chapter on how to integrate the adapters inside SharePoint. I sincerely believe these to be some of the coolest enhancements out there.

Now, back to your question. What you are trying to do is, in my opinion, exactly the kind of things that you should be trying to do in the adapters. Make them work the way you want them to.

Now I have never tried to do what you are suggesting so I am just thinking out loud here. But here is what I think.

In the GridViewAdaptar.cs class file, there is a section called WriteRows(). The basic structure is:

foreach(Gridiew row in rows)
    do some stuff, then:
    foreach(TableCell cell in row.Cells)
        do some more stuff

does that make sense?

so, before the first foreach, i would declare an INT variable, say intColumn, and intantiate it to zero.

then, in the first foreach loop, i would set it to zero again.

then, in the second foreach loop, i increment the variable by 1 for each cell.

something (this is very basic) like this:

int intColumn = 0;
foreach(GridViewRow row in rows)
    intColumn = 0;
    foreach(TableCell cell in row.Cells)

this way, you have access to what column you are on (well, zero-based anyway)

at the end of the second foreach loop, there is a command that looks like this:

cell.CssClass += field.ItemStyle.CssClass;

so, right after that, but before you increment your variable, you might want to insert something like:

if(intColumn = 0)
    cell.HorizontalAlign = HorizontalAlign.Center;

so what would happen is that your counter would reset itself with each row (which is why you are setting it to zero in the first loop). then, in your second loop, you are incrementing your counter with each column so that you can determine which column you are in. then, finally, when you are on the right column, you are setting the horizontal alignment of just that cell.

this is all theoretical, of course, so i would love to hear if this works for you. and, if not, how it breaks. this is fun for me. :D


  #3 (permalink)  
Old April 14th, 2010, 10:04 AM
Authorized User
Join Date: Jan 2010
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elizas
Default How to Customize the Group Text of a DevExPress Grid View

First of all you have to set gcProjectNo.GroupIndex = 0;
Then you have to handle the CustomDrawGroupRow event.

private void grdvProjectList_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDraw EventArgs e)
GridView view = sender as GridView;

DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupR owInfo info =
e.Info as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupR owInfo;

int handle = view.GetDataRowHandleByGroupRowHandle(e.RowHandle) ;

if (info.Column.FieldName == "PRJ_NO")
StringBuilder oGroupText = new StringBuilder();
oGroupText.Append(view.GetRowCellValue(handle, "PRJ_NO").ToString());
oGroupText.Append(" - ");
oGroupText.Append(view.GetRowCellValue(handle, "PRJ_NAME").ToString());

info.GroupText = oGroupText.ToString();
Hope this would be useful.Any suggestions are welcomed.

Mindfire: India's Only Company to be both Apple Premier & Microsoft Gold certified.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
ASP.NET CSS Friendly Control Adapters VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 April 8th, 2008 09:21 PM
3-Column CSS Question kwilliams CSS Cascading Style Sheets 2 April 8th, 2008 02:33 PM
CSS Friendly TBH vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 25th, 2007 01:23 AM
How to add a new column into gridview? Bryan Stanley ASP.NET 2.0 Basics 0 September 12th, 2007 10:49 PM

All times are GMT -4. The time now is 01:35 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.