473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Possible to do Custom Formatting on Gridview

RCM
I have a very simple gridview that is working fine. My real data is
more complicated, but for purposes of my question imagine a grid
display that looks like:

Audi red heavy
Audi blue medium
Audi green medium
Ford red medium
Ford green light
Volks red heavy
Volks red light
Volks yellow heavy

Now, suppose I want to start customizing things. For example, the
first column is actually not editable, so I don't want to see
repeating values and I want the grid to look like:

Audi red heavy
blue medium
green medium
Ford red medium
green light
Volks red heavy
red light
yellow heavy

Or perhaps I just want the auto make to be listed as a subheader row
on its own, as in

Audi
red heavy
blue medium
green medium
Ford
red medium
green light
Volks
red heavy
red light
yellow heavy

And so on and so on - there are obviously all sorts of customizations
one might want to do.

I am having trouble figuring out what is the right/best way to do
these sorts of things. For example, in the first case I described,
where repeating values are to be eliminated, I could certainly go in
and programmatically modify the data to which the grid is bound before
it is bound, but that seems crazy.

And I'm not even sure how the 2nd example would be done. Is there some
event I can hook into when the actual HTML for the grid is being
generated? I don't see anything, but perhaps I am missing it.

Are nested grid views the right answer? Seems like overkill to me, but
maybe that is the way to do it.

Any examples or pointers to good articles with tips on this sort of
gridview customization would be greatly appreciated.

Thanks in advance!
Jan 3 '07 #1
2 1531
This is what the PreRender event for. Populate the grid with all possible
values, like in you first example, and then, in the PreRender event, loop
through the items and hide fields that you don' want to show. This will make
your second example. To come to the third example, you will need to make an
item template containing a table with 2 rows. The model name will go to the
first row and other parameters to the second. In the PreRender event you
will detect the very first item for the model and leave it's first row
visible. Than you will hide the first row for all other items of the same
model.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"RCM" <no**@aol.comwrote in message
news:7l********************************@4ax.com...
>I have a very simple gridview that is working fine. My real data is
more complicated, but for purposes of my question imagine a grid
display that looks like:

Audi red heavy
Audi blue medium
Audi green medium
Ford red medium
Ford green light
Volks red heavy
Volks red light
Volks yellow heavy

Now, suppose I want to start customizing things. For example, the
first column is actually not editable, so I don't want to see
repeating values and I want the grid to look like:

Audi red heavy
blue medium
green medium
Ford red medium
green light
Volks red heavy
red light
yellow heavy

Or perhaps I just want the auto make to be listed as a subheader row
on its own, as in

Audi
red heavy
blue medium
green medium
Ford
red medium
green light
Volks
red heavy
red light
yellow heavy

And so on and so on - there are obviously all sorts of customizations
one might want to do.

I am having trouble figuring out what is the right/best way to do
these sorts of things. For example, in the first case I described,
where repeating values are to be eliminated, I could certainly go in
and programmatically modify the data to which the grid is bound before
it is bound, but that seems crazy.

And I'm not even sure how the 2nd example would be done. Is there some
event I can hook into when the actual HTML for the grid is being
generated? I don't see anything, but perhaps I am missing it.

Are nested grid views the right answer? Seems like overkill to me, but
maybe that is the way to do it.

Any examples or pointers to good articles with tips on this sort of
gridview customization would be greatly appreciated.

Thanks in advance!

Jan 4 '07 #2
RCM
Thanks! - those suggestions got me going in the right direction. In
particular, I didn't even know about templates. That's what I ended up
using.

On Thu, 4 Jan 2007 12:28:55 +0200, "Eliyahu Goldin"
<RE**************************@mMvVpPsS.orgwrote:
>This is what the PreRender event for. Populate the grid with all possible
values, like in you first example, and then, in the PreRender event, loop
through the items and hide fields that you don' want to show. This will make
your second example. To come to the third example, you will need to make an
item template containing a table with 2 rows. The model name will go to the
first row and other parameters to the second. In the PreRender event you
will detect the very first item for the model and leave it's first row
visible. Than you will hide the first row for all other items of the same
model.
Jan 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
3
by: caroh | last post by:
Hi, Can anyone help...I have a gridview control. I wish to highlight certain cells depending on their values. This article mentions a cell formatting event but when I try to import...
1
by: euan | last post by:
HI Guys, I have bee using conditional formatting in the datagrid recently and I am moving over to framework 2.0 and noticed the datagrid has been replaced by the gridview. So, I would like to do...
4
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I...
3
by: CSharpguy | last post by:
I'm trying to format the GridView on my web form and its not working. for money I have {0:C} and for date fields, I have {0:d} and the format isn't changing, what else do I need to do to get the...
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
1
by: AmitKu | last post by:
I've got the Gridview going at full speed, and I've enabled editing, but when I click on the "edit" button, this ugly editing UI comes up. Well it's not ugly, but it's not great either. How do I...
2
by: Greg | last post by:
Hello, I am trying to bind a GridView to a custom object I have created. First, here is what I'm trying to do: I have a wizard for adding/editing Users. When the wizard begins, a User...
1
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.