Problem finding datagrid in Page.controls collection

Discussion in 'ASP .Net' started by Rob, Jul 18, 2003.

  1. Rob

    Rob Guest

    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.


    >-----Original Message-----
    >Hi,
    >I am recursively finding the datagrid in page.controls

    collection. I am able
    >to find everything but not datagrid.
    >Has anyone experienced it before. I am able to find the

    grid using
    >findControl but not within conrols collection using

    typeof operator
    >For Each oControl In pCOntrol
    >
    >if Typeof oControl is DataGrid then
    >
    >....
    >
    >Thanks in advance
    >
    >Regards,
    >
    >
    >
    >.
    >
    Rob, Jul 18, 2003
    #1
    1. Advertising

  2. Rob

    MS Guest

    Thanks Rob,
    But tell me what is "form1" here

    Regards,

    "Rob" <> wrote in message
    news:024001c34d58$2f662530$...
    > 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.
    >
    >
    > >-----Original Message-----
    > >Hi,
    > >I am recursively finding the datagrid in page.controls

    > collection. I am able
    > >to find everything but not datagrid.
    > >Has anyone experienced it before. I am able to find the

    > grid using
    > >findControl but not within conrols collection using

    > typeof operator
    > >For Each oControl In pCOntrol
    > >
    > >if Typeof oControl is DataGrid then
    > >
    > >....
    > >
    > >Thanks in advance
    > >
    > >Regards,
    > >
    > >
    > >
    > >.
    > >
    MS, Jul 18, 2003
    #2
    1. Advertising

  3. Rob

    MS Guest

    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
    "MS" <> wrote in message
    news:%...
    > Thanks Rob,
    > But tell me what is "form1" here
    >
    > Regards,
    >
    > "Rob" <> wrote in message
    > news:024001c34d58$2f662530$...
    > > 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.
    > >
    > >
    > > >-----Original Message-----
    > > >Hi,
    > > >I am recursively finding the datagrid in page.controls

    > > collection. I am able
    > > >to find everything but not datagrid.
    > > >Has anyone experienced it before. I am able to find the

    > > grid using
    > > >findControl but not within conrols collection using

    > > typeof operator
    > > >For Each oControl In pCOntrol
    > > >
    > > >if Typeof oControl is DataGrid then
    > > >
    > > >....
    > > >
    > > >Thanks in advance
    > > >
    > > >Regards,
    > > >
    > > >
    > > >
    > > >.
    > > >

    >
    >
    MS, Jul 18, 2003
    #3
  4. Rob

    Rob Guest

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

    >-----Original Message-----
    >Thanks Rob,
    >But tell me what is "form1" here
    >
    >Regards,
    >
    >"Rob" <> wrote in message
    >news:024001c34d58$2f662530$...
    >> 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.
    >>
    >>
    >> >-----Original Message-----
    >> >Hi,
    >> >I am recursively finding the datagrid in page.controls

    >> collection. I am able
    >> >to find everything but not datagrid.
    >> >Has anyone experienced it before. I am able to find

    the
    >> grid using
    >> >findControl but not within conrols collection using

    >> typeof operator
    >> >For Each oControl In pCOntrol
    >> >
    >> >if Typeof oControl is DataGrid then
    >> >
    >> >....
    >> >
    >> >Thanks in advance
    >> >
    >> >Regards,
    >> >
    >> >
    >> >
    >> >.
    >> >

    >
    >
    >.
    >
    Rob, Jul 19, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeremy Ames

    Adding controls to Page.Controls collection

    Jeremy Ames, Mar 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    1,424
    Peter Blum
    Mar 5, 2004
  2. James Doran
    Replies:
    2
    Views:
    591
    James Doran
    Jun 15, 2004
  3. msnews.microsoft.com
    Replies:
    1
    Views:
    455
    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=
    Sep 26, 2004
  4. Dylan
    Replies:
    5
    Views:
    409
    Daniel T.
    Mar 22, 2005
  5. Øyvind Isaksen
    Replies:
    1
    Views:
    941
    Øyvind Isaksen
    May 18, 2007
Loading...

Share This Page