473,698 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Customize a DataGrid Row


How can I customize a DataGrid row based on the row
properties. For istance if a column is 0 make the row
bold or red. I have only been able to format a datagrid
based on columns.

James
Nov 18 '05 #1
1 1345
Hi,

say in ItemDataBound event handler for the grid you could change the
properties of the DataGridItem (current item being databound). The item is
given in the second event argument of type DataGridItemEve ntArgs for the
event handler method.

Say:

Public Sub MyGrid_ItemData Bound(sender As Object,e As DataGridItemEve ntArgs)
Handles MyGrid.ItemData Bound
If e.Item.ItemType ==ListItemType. Item OrElse
e.Item.ItemType ==ListItemType. AlternatingItem Then
If [somethingevalua tedhere] Then
e.Item.BackColo r=Color.Red
End If
End If
End Sub

The DataGridItem represents the current row (item) as a whole and changing
its properties as I changed BackColor in the example (when condition
matches), you can customize it as you like.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"James Lennon" <an*******@disc ussions.microso ft.com> wrote in message
news:02******** *************** *****@phx.gbl.. .

How can I customize a DataGrid row based on the row
properties. For istance if a column is 0 make the row
bold or red. I have only been able to format a datagrid
based on columns.

James

Nov 18 '05 #2

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

Similar topics

0
1251
by: Christian Dokman | last post by:
Hello, I'd like to know if it is possible to customize a button column in a datagrid. I'd like to do the following: * Give an item in the buttoncolumn a different colour when the mouse goes over the item. Can I add a mouse-event to each item or something to do that? * Can I use Icons instead of the standard linkbutton or can I at least
0
1563
by: Bob Rosen | last post by:
The description given in "Customizing Items Dynamically in the DataList or DataGrid Web Server Control" (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbCode/ html/vbtskCodeCustomizingItemsDynamicallyInDataListWebControlVisualBasic.asp ) says "The examples use the DataList control, but apply to the DataGrid control as well". From what I've experienced, however, that claim isn't quite valid, at least in the case (the...
0
1174
by: Maria | last post by:
Hi I am new to .NET and would like to know how do we customize the apprearance of a datagrid Precisely, I would like to make ONE row appear in BOLD, and I would like to specify the number of significan digits to show in certain rows only. My data source is a DataTable, and it is constructed completely at run-time I want to do the customization AT RUN-TIME, not using VS designer. Is it possible to change the appearance of a particular...
2
1809
by: Hai Ly Hoang | last post by:
Hi, Datagrid is a great control ! But now, i want to customize it : draw a picture on the header row (the topmost row) ! Is it possible ? And how ? Thanks
0
1426
by: MrNobody | last post by:
hey guys... I'm trying to make my DataGrid have selection behavior similar to WindowsExplorer, where I can hold CTRL to add rows to a multi-row selection. Thanks to someone else on this newsgroup, I found out how to detect if CTRL is pressed while in my MouseUp event, which is when it's supposed add that row to the selection. (Otherwise, if the CTRL key is not pressed I clear any current selection to start over- just like Explorer) ...
1
1169
by: Amy Snyder | last post by:
I have a datagrid where I incorporate paging and sorting. My datagrid page mode is set to numeric. Is there a way for me to customize this to display something like this in the page header: Page 1 of 20 Display 50 rows per page The 1 would be in a text box that could be changed from 1-20 to go directly to the page. The 50 would be in a listbox that would allow the
1
1196
by: David Lozzi | last post by:
Hi, I'd like to customize a header in a DataGrid. I want to add a link in the header, as well as pull a recordset's ID. I am using a TemplateColumn so that I can hold several lines of information in one column. The header is now called General Information, I'd like to add an Edit, linked to another page referencing the selected record's ID from a request. And because it is a templatecolumn, I cannot use the built-in edit with DataGrid. ...
0
1817
by: Ray | last post by:
I am trying to add a "Next >" and "<Prev" button to the pager of my datagrid. I have been able to add the hyperlinks to the pager. I am now trying to determine the correct postback script to emulate so that these hyperlinks force the postback of the appropriate linkbuttons in the pager. Let's take a pager with pager: 1 2 3 4 5 It consists of: linkbutton linkbutton label linkbutton linkbutton I want it to be: < Prev 1 2 3 4 5 Next > It...
4
2786
by: Fred | last post by:
Hello, datagrids have GridLines, BorderWidth, BorderColor, ItemStyle.CssClass, ShowFooter ... properties, which can be used to customize the way they look when printed, how does one achieve the same effect for repeaters (this r a few simple pages, i dont wanna use Crystal Reports or anything like that) TIA
0
8675
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, 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...
0
9160
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
8862
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
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
6521
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
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
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
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.