is not a valid identifier

  • Thread starter Thread starter Marc Bishop
  • Start date Start date
M

Marc Bishop

I have an image button control within a repeater control.

<asp:ImageButton id='<%# Container.DataItem("ProductID")%>' runat="server"
ImageUrl="images/noimage.gif" OnClick="RemoveItem" Autopostback="true"/>

but i'm coming up with the error
"<%# Container.DataItem("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.
 
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:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
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:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Back
Top