Accessing Variable from Repeater

Discussion in '.NET' started by beanland, Mar 10, 2010.

  1. beanland

    beanland

    Joined:
    Mar 9, 2010
    Messages:
    1
    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.
     
    beanland, Mar 10, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chris.reed@digus.com

    Repeater control with nested repeater

    chris.reed@digus.com, Feb 11, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    905
    chris.reed@digus.com
    Feb 11, 2005
  2. rwoo_98@yahoo.com
    Replies:
    0
    Views:
    2,936
    rwoo_98@yahoo.com
    Feb 26, 2005
  3. voidfill3d@yahoo.com

    Repeater inside a repeater....how?

    voidfill3d@yahoo.com, Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    7,070
    Karl Seguin
    Aug 10, 2005
  4. uncensored
    Replies:
    0
    Views:
    851
    uncensored
    Oct 25, 2006
  5. Mohanasundaram
    Replies:
    44
    Views:
    1,110
    Keith Thompson
    Aug 24, 2004
Loading...

Share This Page