473,287 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

FindControl in GridView

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)


May 17 '06 #1
2 7515
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)


May 17 '06 #2
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" <cl*****@discussions.microsoft.com> escreveu na mensagem
news:D9**********************************@microsof t.com...
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)


May 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
asp.net 2.0 i have this scenario: <loginview> <loggedintemplate> <formview_1> <gridview> <formview_2>
3
by: Martin | last post by:
Hi, I have a very frustrating problem that I have researched for countless hours to no avail. There are many posts asking very similar things, however none usefull in my situation. I am using VS...
0
by: K B | last post by:
PLEASE be patient and read this. I believe I've actually reached the end of the Web trying to find the answer! I have an aspx using a MasterPage with a ContentPlaceholder. I have a datatable...
6
by: MRW | last post by:
Hello! I have a problem, I can't seem to solve. I'm making a class in my page that will hold the members of a FormView, so I can access them freely throughout the several functions and...
11
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I am trying to get the text of an item in a GridView, but am doing something wrong. Can someone help me with the correct C# statement I need? Below is my GridView and my attempt to get the control....
2
by: kevin | last post by:
Hi. I'm ripping my hair out. I'm in VS 2005 Framework 2. I have one website with a gridview with some template fields. I'm using the footer row to insert records. For this discussion there is a...
1
by: Andrew Robinson | last post by:
I am using the following code to preload a few controls in the FooterRow within a GridView control: protected void Page_Load(object sender, EventArgs e) {...
4
by: beton3000 | last post by:
Hello! I'm building a GridView using code to add template fields, because there is a random number of columns in result set from database. I'm using a class with ITemplate interface for defining...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
1
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
How can I use Findcontrol inside a master gridview's RowDatabound event to search for another gridview (detail) control that is inside an ASP Panel, in a template column of the master gridview?
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.