473,386 Members | 1,708 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,386 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 7522
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.