Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > FindControl in GridView

Reply
Thread Tools

FindControl in GridView

 
 
Bruno Alexandre
Guest
Posts: n/a
 
      05-17-2006
Hi guys,

I have this code:

Dim gv As GridViewRow
Dim str As String = ""
Dim dd As DropDownList

For Each gv In gvItems.Rows
If gv.RowType = DataControlRowType.DataRow Then
str &= gv.RowType.ToString & "<br/>"
dd = CType(gvItems.FindControl("dd1"), DropDownList)
If dd IsNot Nothing Then
str &= "found"
End If
End If
Next

and I can't get into str &= "found"
it doesn't find the control... What I'm doing wrong? the control is showed
in the page! and has the id = "dd1"


Any help?... please.

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)




 
Reply With Quote
 
 
 
 
clickon
Guest
Posts: n/a
 
      05-17-2006
surely this line:

dd = CType(gvItems.FindControl("dd1"), DropDownList)

should read

dd = CType(gv.FindControl("dd1"), DropDownList)

If you want it to look for the control dd1 on each row in the loop.

"Bruno Alexandre" wrote:

> Hi guys,
>
> I have this code:
>
> Dim gv As GridViewRow
> Dim str As String = ""
> Dim dd As DropDownList
>
> For Each gv In gvItems.Rows
> If gv.RowType = DataControlRowType.DataRow Then
> str &= gv.RowType.ToString & "<br/>"
> dd = CType(gvItems.FindControl("dd1"), DropDownList)
> If dd IsNot Nothing Then
> str &= "found"
> End If
> End If
> Next
>
> and I can't get into str &= "found"
> it doesn't find the control... What I'm doing wrong? the control is showed
> in the page! and has the id = "dd1"
>
>
> Any help?... please.
>
> --
>
> Bruno Alexandre
> (a Portuguese in Københanv, Danmark)
>
>
>
>
>

 
Reply With Quote
 
 
 
 
Bruno Alexandre
Guest
Posts: n/a
 
      05-17-2006
got that 2 seconds after post the message, but still wont work, then I tried
again (for the 100th time) search the internet finding a solution and here
it is:

Dim gv As GridViewRow
Dim str As String = ""

For Each gv In gvItems.Rows
If gv.RowType = DataControlRowType.DataRow Then
Dim dropDownListText As String = CType(gv.FindControl("qty"),
DropDownList).SelectedItem.Value
Dim CheckBoxChecked As Boolean = CType(gv.FindControl("rem"),
CheckBox).Checked
If CheckBoxChecked Then
str &= dropDownListText & "<br/>"
End If
End If
Next

I dont know why, but I need to change the names

But now it works perfectly ... I'm so happy!!! it took me 2 days to get
an answer :-/
but know I can help other with the same question
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


"clickon" <(E-Mail Removed)> escreveu na mensagem
news(E-Mail Removed)...
> surely this line:
>
> dd = CType(gvItems.FindControl("dd1"), DropDownList)
>
> should read
>
> dd = CType(gv.FindControl("dd1"), DropDownList)
>
> If you want it to look for the control dd1 on each row in the loop.
>
> "Bruno Alexandre" wrote:
>
>> Hi guys,
>>
>> I have this code:
>>
>> Dim gv As GridViewRow
>> Dim str As String = ""
>> Dim dd As DropDownList
>>
>> For Each gv In gvItems.Rows
>> If gv.RowType = DataControlRowType.DataRow Then
>> str &= gv.RowType.ToString & "<br/>"
>> dd = CType(gvItems.FindControl("dd1"), DropDownList)
>> If dd IsNot Nothing Then
>> str &= "found"
>> End If
>> End If
>> Next
>>
>> and I can't get into str &= "found"
>> it doesn't find the control... What I'm doing wrong? the control is
>> showed
>> in the page! and has the id = "dd1"
>>
>>
>> Any help?... please.
>>
>> --
>>
>> Bruno Alexandre
>> (a Portuguese in Københanv, Danmark)
>>
>>
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FindControl in GridView Bruno Alexandre ASP .Net 3 09-01-2008 10:26 AM
FindControl to reference nested controls in gridview/listview Martin ASP .Net 4 04-10-2008 10:08 AM
Losing Hope! FindControl of dynamic gridview not working K B ASP .Net 2 09-17-2007 12:27 AM
FindControl on GridView Cell returning null saha ASP .Net 0 06-25-2006 06:50 PM
Gridview's findcontrol ignores cells() Edwin Knoppert ASP .Net 0 11-25-2005 09:17 AM



Advertisments