is not a valid identifier

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marc Bishop

    is not a valid identifier

    I have an image button control within a repeater control.

    <asp:ImageButto n id='<%# Container.DataI tem("ProductID" )%>' runat="server"
    ImageUrl="image s/noimage.gif" OnClick="Remove Item" Autopostback="t rue"/>

    but i'm coming up with the error
    "<%# Container.DataI tem("ProductID" )%>' is not a valid identifier"

    how else would i access the ID or value to identify this button control from
    any of the repeat items in the repeater control.

    any help would be great thanks.
    m.


  • S. Justin Gengo

    #2
    Re: is not a valid identifier

    Marc,

    The code you're showing is processed server side. The id you are trying to
    set dynamically is what the server uses to identify the control to the
    code-behind page. (The same one that appears at the bottom of the properties
    window in the design time view if you're using visual studio.net.)

    This would, of course, throw an error since the server is looking for the
    name of the control. What you want to set is the control's client id.

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:


    "Out of chaos comes order."
    Nietzche


    "Marc Bishop" <nonotospammarc bishop@hotmail. com> wrote in message
    news:PZxsb.41$z 53.6@news-binary.blueyond er.co.uk...[color=blue]
    > I have an image button control within a repeater control.
    >
    > <asp:ImageButto n id='<%# Container.DataI tem("ProductID" )%>' runat="server"
    > ImageUrl="image s/noimage.gif" OnClick="Remove Item" Autopostback="t rue"/>
    >
    > but i'm coming up with the error
    > "<%# Container.DataI tem("ProductID" )%>' is not a valid identifier"
    >
    > how else would i access the ID or value to identify this button control[/color]
    from[color=blue]
    > any of the repeat items in the repeater control.
    >
    > any help would be great thanks.
    > m.
    >
    >[/color]


    Comment

    • S. Justin Gengo

      #3
      Re: is not a valid identifier

      Marc,

      To answer the second part of your question (finding which button posted
      back) I'm going to direct you to some sample code. If you go to my web site,
      www.aboutfortunate.com, and then use the search box in the code library to
      search for: "which checkbox clicked in datagrid" you'll find an article
      titled: "How to reference a checkbox, radiobutton, etc. in a datagrid"

      The sample code listed there will show you what you need to do. Doing this
      in a datagrid is almost exactly the same as doing it in a repeater.

      If you have trouble with it at any point feel free to email me.

      Sincerely,


      --
      S. Justin Gengo, MCP
      Web Developer

      Free code library at:


      "Out of chaos comes order."
      Nietzche


      "Marc Bishop" <nonotospammarc bishop@hotmail. com> wrote in message
      news:PZxsb.41$z 53.6@news-binary.blueyond er.co.uk...[color=blue]
      > I have an image button control within a repeater control.
      >
      > <asp:ImageButto n id='<%# Container.DataI tem("ProductID" )%>' runat="server"
      > ImageUrl="image s/noimage.gif" OnClick="Remove Item" Autopostback="t rue"/>
      >
      > but i'm coming up with the error
      > "<%# Container.DataI tem("ProductID" )%>' is not a valid identifier"
      >
      > how else would i access the ID or value to identify this button control[/color]
      from[color=blue]
      > any of the repeat items in the repeater control.
      >
      > any help would be great thanks.
      > m.
      >
      >[/color]


      Comment

      Working...