473,396 Members | 1,871 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.

Problems with GridView.CssClass 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
SelectedRowStyle 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 2728
On 11 May, 17:42, "Jonathan Wood" <jw...@softcircuits.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
SelectedRowStyle 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.softcircuits.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
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...
0
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" />...
6
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...
0
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
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...
4
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...
1
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"...
0
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.