Problem finding datagrid in Page.controls collection

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Problem finding datagrid in Page.controls collection

    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 Guest

  2. Similar Questions and Discussions

    1. A solution to finding controls in datagrid footer...
      Hi all, I saw a lots of developers posting question on finding controls in datagrid footer... I have experimenting differents solution and find...
    2. Adding a control to the DataGrid collection controls
      Hi I have built a DataGrid custom adding a panel of selection automatically produced in base to the columns of the DataGrid The panel has...
    3. Finding the row index in a collection of rows
      So that I can find the pageindex in my datagrid, I need to know the index in a collection of rows where based on a record id. Right now, I have to...
    4. Finding the right page for a row in a datagrid.
      I have an "Add Company" linkbutton on my page that allows a user to add a company. Once the company is added I can re-fill the data adapter and...
    5. Finding the non-matching values collection/array
      Hi all, Ok, lets say I have the following, Request.Form collection which produces this (as the element names) a b c d
  3. #2

    Default Re: Problem finding datagrid in Page.controls collection

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

    Regards,

    "Rob" <orkeytell@hotmail.com> wrote in message
    news:024001c34d58$2f662530$a301280a@phx.gbl...
    > 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 Guest

  4. #3

    Default Re: Problem finding datagrid in Page.controls collection

    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" <MNadeemAkhter@lycos.com> wrote in message
    news:%23aLqlgWTDHA.2180@TK2MSFTNGP10.phx.gbl...
    > Thanks Rob,
    > But tell me what is "form1" here
    >
    > Regards,
    >
    > "Rob" <orkeytell@hotmail.com> wrote in message
    > news:024001c34d58$2f662530$a301280a@phx.gbl...
    > > 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 Guest

  5. #4

    Default Re: Problem finding datagrid in Page.controls collection

    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" <orkeytell@hotmail.com> wrote in message
    >news:024001c34d58$2f662530$a301280a@phx.gbl...
    >> 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139