473,890 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change color of cell in column if...

2 New Member

Im new in c# :)

I wonder how to change color of some cell if there is some criteria.

ie. if value in cell = John then color of that cell is Red

This very easy in PHP but c#.. :(

I need that on column:

Expand|Select|Wrap|Line Numbers
  1. <asp:BoundColumn DataField="ListName" HeaderText="List name" ></asp:BoundColumn>
here is my code:

Expand|Select|Wrap|Line Numbers
  2. <html xmlns="http://www.w3.org/1999/xhtml" >
  3. <head runat="server">
  4.     <title>List</title>
  5.     <link href="../b2a.css" rel="stylesheet" type="text/css" />
  6. </head>
  7. <body>
  8.         <form id="Form1" method="post" runat="server">
  9.             <table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
  10.                 <tr>
  11.                     <td></td>
  12.                 </tr>
  13.                 <tr>
  14.                     <td><asp:DataGrid id="dGrupe" runat="server" CssClass="nk" width="440px" autogeneratecolumns="False" OnCancelCommand="CancelItem" OnDeleteCommand="DeleteItem" OnEditCommand="EditItem" OnItemCommand="Select" OnItemDataBound="dgGrupe_ItemDataBound" OnUpdateCommand="UpdateItem">
  15.                             <SelectedItemStyle CssClass="kFooter"></SelectedItemStyle>
  16.                             <EditItemStyle CssClass="kFooter"></EditItemStyle>
  17.                             <alternatingitemstyle cssclass="nk2"></alternatingitemstyle>
  18.                             <itemstyle cssclass="n1"></itemstyle>
  19.                             <headerstyle cssclass="n" backcolor="#EBEBEB"></headerstyle>
  20.                             <columns>
  21.                                 <asp:BoundColumn Visible="False" DataField="IDListe" ReadOnly="True"></asp:BoundColumn>
  22.                                 <asp:BoundColumn DataField="ListName" HeaderText="List name" ></asp:BoundColumn>
  23.                                 <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
  24.                                 <asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
  25.                                 <asp:ButtonColumn Text="Select" CommandName="Select"></asp:ButtonColumn>
  26.                             </columns>
  27.                         </asp:DataGrid></td>
  28.                 </tr>
Jul 11 '07 #1
0 1442

Sign in to post your reply or Sign up for a free account.

Similar topics

by: SarahMarsden | last post by:
I'm new to Dreamweaver (using MX 2004). I have a 2 row 3 column table. I have set each column to 200 pixels. The second row I have merged into one cell. When I enter text (or anything else) into the merged cell the 3 columns above change pixel width. The pixel width still says 200. But the pixel width shown in green above the columns it says 200(172)for example. It seems that the bracketed number is the size the cell displays at rather...
by: Barney Nicholls | last post by:
I have a datagrid and want to change the background color of the end column to denote that it is the only column that is not read only. I still want this column to be editable. I've found examples that let you change the background color of the cell but it but the cell no longer appears to be editable.
by: Richard | last post by:
I'm trying to change a value of a cell based on another before the grid is displayed. I'm using the ItemDataBound event like this for a simple test: Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem If e.Item.Cells(7).Text = String.Empty Then e.Item.Cells(7).Text = "hello" End If End Select
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to make sure entry is valid? Thanks, Rog
by: Tommy | last post by:
Hi all, I use DataGridView in my form and add image column and 2 textbox column, and I want to change image column's image on runtime. But there is no any example on this function. What can I do ? More thanks Tommy
by: rob | last post by:
I have a class that among others exposes a string property "Date". The date in this property is stored in the form yyyymmdd. Now I do the following 1) Generate a DataGridViewTextBoxColumn column for that property 2) Add the column to the datagridview 3) Populate a BindingSource by adding all instances of the above mentioned class. 4) Assign the BindingSource to the datagridview's DataSource property
by: free4trample | last post by:
First of all let me say that I know very little about javascript. what i need to do is to write a javascript functin which will change the background color of the table rows based on entrees in the table. See an example of the webpage that the script will work with here: http://igorpetrusky.awardspace.com/RunStats.html now, at the top there will be 3 buttons, which will call javascript functions that will operate on tables 2 through N. ...
by: satish | last post by:
I have a table with two columns field1 int,Field2 and added a column to datagrid on runtime sum (field1+field2) ,upon changing the data in either of the fileds the sum field or column too changes . Intially there will be data in the fields ..and ii try to change the value of column so the column also changes,Can i change the colour of the cells where the data has been changed .I have found out the cells where the data has been changed i...
by: joinzulfi | last post by:
Dear fellows! I have designed a form having SaleMasterTable and SaleDetailTable. SaleDetailTable is Bounded with DataGrid. Now I want that if in2nd Column's cell (it is combobox) value is changed then as a result of this change in 3rd column's cell (it is textbox) value is inserted from another table in database named Product.
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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...
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...
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,...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.