473,772 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with GridView.CssCla ss and Selections

Greetings,

On a GridView control, I want to show alternating colors. But instead of
alternating on each row, I want to alternate each group. So several items
would be one color and the next several items would be another color.

I'm able to accomplish this by setting the CssClass property in the
GridView's RowDataBound event handler.

But I also need the rows to be selectable so I set the CssClass for the
SelectedRowStyl e at design time. The problem is that, when CssClass is set
in the RowDataBound event handler, that style is always used, even when the
row is selected. And these rows no longer provide any visual indication that
they are selected.

It appears that ASP.NET will not override a manually set CssClass with the
selected row CssClass.

Does anyone know how I could make this work?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Jun 27 '08 #1
1 2747
On 11 May, 17:42, "Jonathan Wood" <jw...@softcirc uits.comwrote:
Greetings,

On a GridView control, I want to show alternating colors. But instead of
alternating on each row, I want to alternate each group. So several items
would be one color and the next several items would be another color.

I'm able to accomplish this by setting the CssClass property in the
GridView's RowDataBound event handler.

But I also need the rows to be selectable so I set the CssClass for the
SelectedRowStyl e at design time. The problem is that, when CssClass is set
in the RowDataBound event handler, that style is always used, even when the
row is selected. And these rows no longer provide any visual indication that
they are selected.

It appears that ASP.NET will not override a manually set CssClass with the
selected row CssClass.

Does anyone know how I could make this work?

Thanks.

--
Jonathan Wood
SoftCircuits Programminghttp ://www.softcircuit s.com
As you are setting the normal styles at run time it is necessary to do
the same the for the selected row. In the RowDatabound event handler
where you are assigning the CssClass you can check whether the row
being processed is selected or not by comparing e.row.RowIndex with
the GridView SelectedIndex property. If they match then apply the
selected row style - you could even vary this according to which group
the row is in.
Jun 27 '08 #2

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

Similar topics

6
24747
by: Tim Cartwright | last post by:
I am trying to figure out how to change the gridview caption style, but I can not figure out how. I added table caption { background-color: #5D7B9D; color: White; font-size: 16pt; } to my CSS, yet when the page renders, the grids style take precendence, as
0
1095
by: zerosleep | last post by:
I want to do this (some props removed intentionally): ..skin file: <asp:GridView SkinID="GridThemeA"> <RowStyle CssClass="someClass" /> <AlternatingRowStyle CssClass="someAltClass" /> <Columns> <asp:TemplateField HeaderText="MyHeaderText"> <HeaderStyle CssClass="HeaderClass" />
6
2395
by: Dabbler | last post by:
I have a GridView with a couple of TemplateFields. When I click the update link the Gridview returns to display mode with no errors but the data from bound text fields or dropdown list isn't updated in the table. I'm stumped and any help would be appreciated. Thanks much. My GridView: <asp:GridView ID="VanListGridView" runat="server"
0
1768
by: jobo | last post by:
Hey there, I'm having a problem getting sorting to work. Here's what the GridView looks like: "server" ID="updt1" Mode="Conditional">
4
4189
by: chris | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
4
3487
by: =?Utf-8?B?Y2hyaXM=?= | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
1
10408
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID" OnRowCreated="ContactHistoryGrid_RowCreated" CssClass="GridViewTable" GridLines="None" CellSpacing="1" CellPadding="3" AllowSorting="True" AllowPaging="True"> <EmptyDataTemplate>
0
4666
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
0
2535
KalariaNitya
by: KalariaNitya | last post by:
Hello, could anybody help me? i have gridview, inside gridview i have one Update button & textbox update button update the quantity entered in textbox. i want to update the quantity on textbox on ENTER event. i had done below code: page_load()
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.