Groups | Blog | Home
all groups > asp.net datagrid control > may 2004 >

asp.net datagrid control : access control in header template



royguard NO[at]SPAM hotmail.com
5/27/2004 7:06:14 PM
I got a label control which is dynamically created inside the
headerTemplate of template column.
And it is part of the datagrid.


Please teach me how to read the content of that label control?

I cannot use FindControl() function because it is created in runtime
based on variable.
And everytime the number of columns is different.

I can access a textbox control in itemTemplate with following code
(dgassignment is the datagrid)

dim i as integer
dim j as integer
dim textboxhour as textbox
dim dgi as datagriditem

for i = 0 to dgassignment.items.count -1
dgi = dgassignment.items(i)
for j = 0 to dgi.cells.count -1
textboxhour = ctype(dgi.cells(j).controls(0), textbox)
next j
next i

But I have no idea how to get the control in header, please help,
Ben Miller [MSFT]
6/1/2004 10:26:00 PM
Couldn't you just use the ItemDataBound event on the datagrid and test for
the itemType = Header?

sub DataGrid_ItemDataBound(sender as object, e as DataGridItemEventArgs)
if e.Item.ItemType = ListItemType.Header Then
do a findcontrol() here.
end if
end Sub

HTH.
Ben Miller
--
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


[quoted text, click to view]

AddThis Social Bookmark Button