473,288 Members | 1,729 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,288 software developers and data experts.

format grid column (all of them)

I've seen stuff on changing row colors based on something, i've seen how to
create columns on the fly, how can I change an color of the entire column
based on certain criteria?

I need to change the color (highlight) an entire column(s) of my grids based
on what the user selected in the drop down
Nov 18 '05 #1
5 1426
If you give your rows a unique id it's pretty easy

<select onSelectIndexChange="HighLightRow(this)"><option.. ..>...</select>
<table>
<tr id="1">
<td></td>
<td></td>
</tr>
<tr id="2">
<td></td>
<td></td>
</tr>
<tr id="3">
<td></td>
<td></td>
</tr>
</table>
notice they don't have a runat="Server"....they are just client-side Ids..

<script language="javascript">
function HighLightRow(sel){
var tr = null;
switch (sel.options[sel.selectedIndex].value){
case "1":
tr = document.getElementsById("1");
break;
case "blah";
tr = document.getElementsById("2");
break;
}
var tds = td.getElementsByTagName("td");
for (var i = 0; i < tds.length; ++i){
tds[i].className = 'highlightedClass';
}
}
</script>

something like that ought to work.
"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I've seen stuff on changing row colors based on something, i've seen how to create columns on the fly, how can I change an color of the entire column
based on certain criteria?

I need to change the color (highlight) an entire column(s) of my grids based on what the user selected in the drop down

Nov 18 '05 #2
Yes, I know..it won't matter...when it gets rendered to the client it's all
just normal html...I was just making sure you didn't put a runat="server" in
there..

As long as you can get a unique id="xxx" in each <tr>, you'll be set.

Karl

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I've seen stuff on changing row colors based on something, i've seen how to create columns on the fly, how can I change an color of the entire column
based on certain criteria?

I need to change the color (highlight) an entire column(s) of my grids based on what the user selected in the drop down

Nov 18 '05 #3
I can't put a unique id on it the tables due to 1 only have 3 grids and each
one displays different data per selection.
Example:

Grid 1 displays everything on cars
it also displays everything on trucks
different headers and different dataitems

grid 2 shows everythng on boats
cruisers, yachts, etc
again, dffierent headers (some are added and removed)
and different data items

etc
"Karl" wrote:
Yes, I know..it won't matter...when it gets rendered to the client it's all
just normal html...I was just making sure you didn't put a runat="server" in
there..

As long as you can get a unique id="xxx" in each <tr>, you'll be set.

Karl

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I've seen stuff on changing row colors based on something, i've seen how

to
create columns on the fly, how can I change an color of the entire column
based on certain criteria?

I need to change the color (highlight) an entire column(s) of my grids

based
on what the user selected in the drop down


Nov 18 '05 #4
I figured it out and i didn't use the javascript.

this does it

dgCars.Columns(4).ItemStyle.BackColor = System.Drawing.Color.yellow

"IGotYourDotNet" wrote:
I can't put a unique id on it the tables due to 1 only have 3 grids and each
one displays different data per selection.
Example:

Grid 1 displays everything on cars
it also displays everything on trucks
different headers and different dataitems

grid 2 shows everythng on boats
cruisers, yachts, etc
again, dffierent headers (some are added and removed)
and different data items

etc
"Karl" wrote:
Yes, I know..it won't matter...when it gets rendered to the client it's all
just normal html...I was just making sure you didn't put a runat="server" in
there..

As long as you can get a unique id="xxx" in each <tr>, you'll be set.

Karl

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I've seen stuff on changing row colors based on something, i've seen how

to
create columns on the fly, how can I change an color of the entire column
based on certain criteria?

I need to change the color (highlight) an entire column(s) of my grids

based
on what the user selected in the drop down


Nov 18 '05 #5
Hello

u can do the following in ur ItemCreated event

If e.Item.ItemType = "ur required type"
If (check ur condition here)
e.Item.BackColor = System.Drawing.Color.Aqua;

else

gridItem.BackColor = System.Drawing.Color.Azure ;

here e is the DataItem that u'll receive as parameter in that event.....

hope this will help u

smiles,

Laiju

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com...
I don't think this will work since all the rows in my datagrid are databound (form runat=server>

is not a regular html table until runtime. I
I'll give it a shot though and see what happens

"Karl" wrote:
If you give your rows a unique id it's pretty easy

<select onSelectIndexChange="HighLightRow(this)"><option.. ..>...</select> <table>
<tr id="1">
<td></td>
<td></td>
</tr>
<tr id="2">
<td></td>
<td></td>
</tr>
<tr id="3">
<td></td>
<td></td>
</tr>
</table>
notice they don't have a runat="Server"....they are just client-side Ids..
<script language="javascript">
function HighLightRow(sel){
var tr = null;
switch (sel.options[sel.selectedIndex].value){
case "1":
tr = document.getElementsById("1");
break;
case "blah";
tr = document.getElementsById("2");
break;
}
var tds = td.getElementsByTagName("td");
for (var i = 0; i < tds.length; ++i){
tds[i].className = 'highlightedClass';
}
}
</script>

something like that ought to work.
"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message news:96**********************************@microsof t.com...
I've seen stuff on changing row colors based on something, i've seen how
to
create columns on the fly, how can I change an color of the entire

column based on certain criteria?

I need to change the color (highlight) an entire column(s) of my grids

based
on what the user selected in the drop down


Nov 18 '05 #6

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

Similar topics

13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
3
by: Peter | last post by:
I have a datagrid on WinForm and I am trying to format the Grid. I am using the following code, the code runs fine, but nothing happens after it runs, the datagrid does not change (with data in the...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
3
by: Daniel M. | last post by:
I have a query that gets a string column containing a date, ex. 20040825. If I use the property builder to format the string to 08/25/2004 it does not work because it only accepts datetime columns....
4
by: Carlos Lozano | last post by:
Hello Folks! I have a grid that populates from a table on SQL Server. All datetime with DBNull value show 1/1/1900 12:00AM ... Instead of just blank (""). I found a document with the following...
6
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
2
by: skanemupp | last post by:
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons...
1
by: Francesco Bochicchio | last post by:
Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto: Uhm, I don't think you should use the grid manager to obtain a window like that. The grid manager is for equally distributing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.