Problem finding datagrid in Page.controls collection

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

You can find datagrid in page by refering the form.
Gatagrid is a child control of Form.

Here is the code
-----------------

Dim ctl As New Control
For Each ctl In Page.FindControl("form1").Controls
If TypeOf ctl Is DataGrid Then
Response.Write(ctl.ID)
End If

Next


Let me know if it works.
 
Ok I figure it out it is the ID of page in HTML.Another question is; Is
there any way I can findout this property without hardcoding it?

Thanks in advance
 
You need to specify the data grid within the form.
Form1 is the id of Form. I think this answers your
question.
 
Back
Top