access control in header template

M

mor

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,
thanks.
 
B

Ben Miller [MSFT]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top