473,545 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = DataControlRowT ype.DataRow Then
str &= gv.RowType.ToSt ring & "<br/>"
dd = CType(gvItems.F indControl("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 7527
surely this line:

dd = CType(gvItems.F indControl("dd1 "), DropDownList)

should read

dd = CType(gv.FindCo ntrol("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 = DataControlRowT ype.DataRow Then
str &= gv.RowType.ToSt ring & "<br/>"
dd = CType(gvItems.F indControl("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 = DataControlRowT ype.DataRow Then
Dim dropDownListTex t As String = CType(gv.FindCo ntrol("qty"),
DropDownList).S electedItem.Val ue
Dim CheckBoxChecked As Boolean = CType(gv.FindCo ntrol("rem"),
CheckBox).Check ed
If CheckBoxChecked Then
str &= dropDownListTex t & "<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*****@discus sions.microsoft .com> escreveu na mensagem
news:D9******** *************** ***********@mic rosoft.com...
surely this line:

dd = CType(gvItems.F indControl("dd1 "), DropDownList)

should read

dd = CType(gv.FindCo ntrol("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 = DataControlRowT ype.DataRow Then
str &= gv.RowType.ToSt ring & "<br/>"
dd = CType(gvItems.F indControl("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
2213
by: Phil | last post by:
asp.net 2.0 i have this scenario: <loginview> <loggedintemplate> <formview_1> <gridview> <formview_2>
3
19329
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 2005 (ASP 2.0) and VB .NET. I have a page with a datalist, a gridview and then other data controls, nested in that order. This all works great,...
0
2374
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 that I use to dynamically populate a gridview - I have to do this in order to specify which control type to put in one of the columns. All this works...
6
1700
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 subroutines, without having to redefine them every function/subroutine. I ran into a problem when trying to define a GridView in that FormView and I was...
11
1879
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. Thank you. string option = ((TextBox)dgDropDownMenus.Items.FindControl("txtName")).Text; ...
2
13050
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 textbox and a linkbutton in the footer row. In the click event of the linkbutton an example of what I'm doing is this: Dim txt as textbox =...
1
7949
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) { ((TextBox)GriwViewRates.FooterRow.FindControl("TextBoxRateInsert")).Text = "60"; } The successfully loads the Footer / TextBox on page load but fails to load the Footer / TextBox when...
4
9013
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 columns. I am using a code which adds a checkbox for each column: public void InstantiateIn(System.Web.UI.Control container) { switch...
4
10994
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 to iterate thru the gridview's rows, examine the databound controls, then perform a database action. for some reason, i can't find the controls. ...
1
1998
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
7479
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7411
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7439
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.