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
sloan - 06 Feb 2008 19:41 GMT
That is designed behavior.
When its inside a datagrid (repeater, gridview) etc... you could N number of
these.
FindControl
http://www.google.com/search?source=ig&hl=en&rlz=&q=datagrid+FindControl
That'll get you on the right path.
>I have the following code in the aspx
>
[quoted text clipped - 14 lines]
> thanks
> shannon
jvcoach23 - 06 Feb 2008 19:50 GMT
ok.. that makes sense.. thanks
> That is designed behavior.
>
[quoted text clipped - 24 lines]
>> thanks
>> shannon
Mark Moeykens - 06 Feb 2008 21:14 GMT
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("lblRightWrong"), Label).Text =
"Correct"
Hope this gets you started in the right direction!
Mark Moeykens
> I have the following code in the aspx
>
[quoted text clipped - 13 lines]
> thanks
> shannon