is not a valid identifier

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.
 
S

S. Justin Gengo

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
 
S

S. Justin Gengo

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
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top