Accessing Variable from Repeater

Joined
Mar 9, 2010
Messages
1
Reaction score
0
Hello,

I am trying to set up a repeater and have certain data be displayed conditionally. This is done by comparing something in Databinder.Eval to a variable I have. However, I keep getting the following error:

Code:
CS0103: The name 'SubmitTo' does not exist in the current context

This is coming from the following code:

Code:
<select name="newSubmitTo">
<ASP:Repeater id="rSubmitTo" runat="server">
<ItemTemplate>
<option value="<%#DataBinder.Eval(Container.DataItem , "PERSONID")%>" [COLOR="Green"]<%#DataBinder.Eval(Container.DataItem, "PERSONID").ToString().Equals(SubmitTo) ? "selected" : "" %>[/COLOR]><%#DataBinder.Eval(Container.DataItem, "PERSONFULLNAME")%></option>
</ItemTemplate>
</ASP:Repeater>
</select>

I've highlighted the offending bit of code. Now, this perplexes me because when I want to interact with this variable outside of the Repeater, I have no problem whatsoever--

<%Response.Write(SubmitTo);%> works both before the <ASP:Repeater> tag and after its ending </ASP:Repeater> tag.

If I change the following

Code:
<%#DataBinder.Eval(Container.DataItem, "PERSONID").ToString().Equals(SubmitTo) ? "selected" : "" %>

to this

Code:
<%#DataBinder.Eval(Container.DataItem, "PERSONID").ToString().Equals(63) ? "selected" : "" %>

How can I get the variable to work in this context? Any help would be appreciated. Thank you for your time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top