473,735 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid Header from TableCell

During grid field validation, I would like to generate a message for
the user to tell which column had the error. So I have a control
(textbox, dropdownlist, checkbox, etc.), and would like to grab the
header text from its column. I can't find any direct link from the
TableCell (the control's parent) to the table column.

I know the TableCell has a ClientID, and the last chars will be a
number, but that number doesn't always represent the actual column.
Some of the left-side columns of my grid are sometimes hidden
(display=none), and the number in the TableCell.clien tID relates only
to the visible columns. So I can't count on the TableCell number
telling me the right column number.

In the code here, I loop through the DataGridItem cells, counting
columns, until I find the right TableCell.

Public Function GetColumnName(B yVal obj As Object) As String
Dim i As Integer
For i = 0 To CType(obj.paren t.parent,
DataGridItem).C ells.Count - 1
If CType(obj.paren t, TableCell).Clie ntID =
CType(obj.paren t.parent, DataGridItem).C ells(i).ClientI D Then
Return CType(obj.Paren t.Parent.Parent .Parent,
DataGrid).Colum ns(i).HeaderTex t
End If
Next
Return ""
End Function

The code works fine, but I was hoping for a more elegant solution. Is
there one?

I'm using .NET Framework v1.1.

Thanks
Dan
Jun 27 '08 #1
0 907

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

Similar topics

1
7904
by: Mike Irwin | last post by:
I'm trying to add an attribute to each column header of a DataGrid. I know that I need to do this within the ItemCreated event of the DataGrid, but I'm stuck on how to go any further. I found some info on MSDN on how to do this, but it's doesn't clear any thing up for me Here's the paragraph and a link to the document: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcondatagridwebservercontrol.asp ...
4
2156
by: spammy | last post by:
Hi all, Is it possible to create subheaders in datagrids? Or rather to add a parent header row to an existing datagrid? Currently my DG looks like this: NAME | A - PART1 | A - PART2 | A - PART3 | B - PART1 | B - PART2 whereas id like it to look like: NAME | A | B |
0
1244
by: Eric | last post by:
Hello, I have a datagrid with sorting enabled. When clickong on the colum names in the header the datagrid is sorted no problem. Unfortunatly, I have a graph that needs to be generated for each colum as well. I'd like to have an additonal header at the top of the datagrid that has an imagebutton for each colum that would generate the graph. I've successfully created the second header and programatically added the imagebutton to the...
2
1726
by: rooster575 | last post by:
I would like my datagrid to have the following format: ID - Name - Phone Title - Birthday - email Is this possible for the header and result items? Thanks.
2
4234
by: saleek | last post by:
I was wondering if there is a way I can add an extra header to a datagrid? I found this solution on the internet - but it seems quite old and didn't work for me. http://www.dotnet247.com/247reference/msgs/13/69744.aspx It recommends the following: Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
1
3444
by: sri_san | last post by:
Hello, I have a datagrid in which the header needs to span over 2 columns. I have tried creating a tableCells and tableRow at runtime and set the columnspan property of a cell to 2. But, the heading does not look good and is not aligned to the datagrid columns. Is there another way to do it? Any help would be great!! Thanks, Sam.
1
2277
by: Olav Tollefsen | last post by:
Is it possible to create a DataGrid footer to span multiple columns? Olav
1
1919
by: Nicky | last post by:
hi, all I have a asp.net page, and there is a DataGrid in it. I want show it like Header: ID, StartTime, EndTime....... 1 12:20 12:40 This is the job which is ........ 2 14:30 14:45 This is the second job ........ Here, each item contains two row.What is the best solution for this? Or I should not use DataGrid for it?
4
4723
by: Mortar | last post by:
i need a datagrid with 2 header columns. The top one might have 1 column spanning 5 columns of the header row below it. what is the best way to do this? Could i have 2 datatables...1 filling the top row, and the 2nd header row would come from the 2nd datatable? In this case, i guess i would have to add a row manually above the header row (2nd dataset) which is the set of 1st data? if someone has ideas, code explaining it would be very...
0
8958
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
9323
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
9248
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
9193
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
8196
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
6747
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
6045
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
4555
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...
3
2186
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.