473,396 Members | 1,921 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,396 software developers and data experts.

code behind not seeing a label

I have the following code in the aspx

<asp:Label ID="lblRightWrong" runat="server" />

that is inside a datagrid, itemtemplate

the vb code behind

Me.lblRightWrong.text = "Correct"

but the lblRightWrong says that it does not exists... I've tried exiting
out of VS, tried to recreate it, nothin seems to work.. it always can't see
it. i'm on VS 2005, sp1. anyone have any ideas as to why it won't show
up... all my other referrences to the aspx page are working

thanks
shannon
Feb 6 '08 #1
1 1268
This is correct, Shannon. Say your grid has 10 rows, then that label is
recreated 10 times. So if you try to set it, it doesn't know which one of the
10 you want to set.
So your page is working correctly, you just have to tweak it a bit to set
that label.

If you know ahead of time what the row index is that you want to change, you
can probably use code like this:

Dim rowIndex As Integer
rowIndex = 2
CType(GridView1.Rows(rowIndex).FindControl("lblRig htWrong"), Label).Text =
"Correct"
Hope this gets you started in the right direction!

Mark Moeykens
"jvcoach23" wrote:
I have the following code in the aspx

<asp:Label ID="lblRightWrong" runat="server" />

that is inside a datagrid, itemtemplate

the vb code behind

Me.lblRightWrong.text = "Correct"

but the lblRightWrong says that it does not exists... I've tried exiting
out of VS, tried to recreate it, nothin seems to work.. it always can't see
it. i'm on VS 2005, sp1. anyone have any ideas as to why it won't show
up... all my other referrences to the aspx page are working

thanks
shannon
Feb 6 '08 #2

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

Similar topics

3
by: Coco | last post by:
Hi! I managed to display chinese character in my web form (.aspx), in certain situation i need to to set the text of the label of my web form in chinese character programatically which is done in...
6
by: thejackofall | last post by:
I added a label server control in my aspx file. In the code behind, the IDE does not generate the corresponding object like it does with buttons and other objects. What am I doing wrong? Is...
2
by: Ken Tucker | last post by:
I've read about this issue in many articles across the net... But haven't found a solution. I see all kinds of custom code to perform sorting with datagrids, but my example is so simple, I must...
5
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my...
5
by: Haydnw | last post by:
Hi, I have the code below as code-behind for a page which displays two images. My problem is with the second bit of code, commented as " 'Portfolio image section". Basically, the SQL query gets...
3
by: Prince | last post by:
I have strange problem. If in Design Mode and I drag a Web Server Control onto the form, Visual Studio automatically declares the control for me in the code behind page. However, if I'm...
2
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a...
2
by: Kurt Schroeder | last post by:
Still new to code behind so i'm not sure what the problem is (i'm using visualStudio.net for the first time) like my last question i'll bet this has a quick answer. thanks kes here is the error:...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.