Connecting Tech Pros Worldwide Help | Site Map

Problem finding datagrid in Page.controls collection

Rob
Guest
 
Posts: n/a
#1: Nov 17 '05
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.

[color=blue]
>-----Original Message-----
>Hi,
>I am recursively finding the datagrid in page.controls[/color]
collection. I am able[color=blue]
>to find everything but not datagrid.
>Has anyone experienced it before. I am able to find the[/color]
grid using[color=blue]
>findControl but not within conrols collection using[/color]
typeof operator[color=blue]
>For Each oControl In pCOntrol
>
>if Typeof oControl is DataGrid then
>
>....
>
>Thanks in advance
>
>Regards,
>
>
>
>.
>[/color]
MS
Guest
 
Posts: n/a
#2: Nov 17 '05

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...[color=blue]
> 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.
>
>[color=green]
> >-----Original Message-----
> >Hi,
> >I am recursively finding the datagrid in page.controls[/color]
> collection. I am able[color=green]
> >to find everything but not datagrid.
> >Has anyone experienced it before. I am able to find the[/color]
> grid using[color=green]
> >findControl but not within conrols collection using[/color]
> typeof operator[color=green]
> >For Each oControl In pCOntrol
> >
> >if Typeof oControl is DataGrid then
> >
> >....
> >
> >Thanks in advance
> >
> >Regards,
> >
> >
> >
> >.
> >[/color][/color]


MS
Guest
 
Posts: n/a
#3: Nov 17 '05

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...[color=blue]
> Thanks Rob,
> But tell me what is "form1" here
>
> Regards,
>
> "Rob" <orkeytell@hotmail.com> wrote in message
> news:024001c34d58$2f662530$a301280a@phx.gbl...[color=green]
> > 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.
> >
> >[color=darkred]
> > >-----Original Message-----
> > >Hi,
> > >I am recursively finding the datagrid in page.controls[/color]
> > collection. I am able[color=darkred]
> > >to find everything but not datagrid.
> > >Has anyone experienced it before. I am able to find the[/color]
> > grid using[color=darkred]
> > >findControl but not within conrols collection using[/color]
> > typeof operator[color=darkred]
> > >For Each oControl In pCOntrol
> > >
> > >if Typeof oControl is DataGrid then
> > >
> > >....
> > >
> > >Thanks in advance
> > >
> > >Regards,
> > >
> > >
> > >
> > >.
> > >[/color][/color]
>
>[/color]


Rob
Guest
 
Posts: n/a
#4: Nov 17 '05

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.
[color=blue]
>-----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...[color=green]
>> 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.
>>
>>[color=darkred]
>> >-----Original Message-----
>> >Hi,
>> >I am recursively finding the datagrid in page.controls[/color]
>> collection. I am able[color=darkred]
>> >to find everything but not datagrid.
>> >Has anyone experienced it before. I am able to find[/color][/color][/color]
the[color=blue][color=green]
>> grid using[color=darkred]
>> >findControl but not within conrols collection using[/color]
>> typeof operator[color=darkred]
>> >For Each oControl In pCOntrol
>> >
>> >if Typeof oControl is DataGrid then
>> >
>> >....
>> >
>> >Thanks in advance
>> >
>> >Regards,
>> >
>> >
>> >
>> >.
>> >[/color][/color]
>
>
>.
>[/color]
Closed Thread