473,324 Members | 2,193 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,324 software developers and data experts.

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.clientID 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(ByVal obj As Object) As String
Dim i As Integer
For i = 0 To CType(obj.parent.parent,
DataGridItem).Cells.Count - 1
If CType(obj.parent, TableCell).ClientID =
CType(obj.parent.parent, DataGridItem).Cells(i).ClientID Then
Return CType(obj.Parent.Parent.Parent.Parent,
DataGrid).Columns(i).HeaderText
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 884

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

Similar topics

1
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...
4
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 -...
0
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...
2
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
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. ...
1
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...
1
by: Olav Tollefsen | last post by:
Is it possible to create a DataGrid footer to span multiple columns? Olav
1
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 ...
4
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...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.