Data binding with a repeater

G

Guest

I'm having a problem getting the data binding to work with the repeater control. Here's the code for the code-behind class

private void Page_Load(object sender, System.EventArgs e

if (!this.IsPostBack

DataView dv = new DataView(AlbumMgr.Instance.GetAlbumsList())

rptalbums.DataSource = dv
rptalbums.DataBind()



Here's the script for the repeater

<asp:Repeater id="rptalbums" runat="server"><ItemTemplate><tr><td class="alternate" width="*"><a href="#" onclick='SelectAlbum(<%# DataBinder.Eval(Container.DataItem, "AlbumKey");%>); return false;' target="frmmain"><%# DataBinder.Eval(Container.DataItem, "Title");%></a></td><td class="alternate" width="16px"><a href="#" onclick='RemoveAlbum(<%# DataBinder.Eval(Container.DataItem, "AlbumKey");%>); return false;'><img border="0" src="images/trash.gif" /></a></td></tr></ItemTemplate><AlternatingItemTemplate><tr><td class="alternate" width="*"><a href="#" onclick='SelectAlbum(<%# DataBinder.Eval(Container.DataItem, "AlbumKey");%>); return false;' target="frmmain"><%# DataBinder.Eval(Container.DataItem, "Title");%></a></td><td class="alternate" width="16px"><a href="#" onclick='RemoveAlbum(<%# DataBinder.Eval(Container.DataItem, "AlbumKey");%>); return false;'><img border="0" src="images/trash.gif" /></a></td></tr></AlternatingItemTemplate><--snip--

No matter what I try, I always get error "CS1026: ) expected"

Could anyone point out what I am doing wrong?
 
J

John Saunders

Paul K said:
I'm having a problem getting the data binding to work with the repeater
control. Here's the code for the code-behind class:
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.IsPostBack)
{
DataView dv = new DataView(AlbumMgr.Instance.GetAlbumsList());

rptalbums.DataSource = dv;
rptalbums.DataBind();
}
}

Here's the script for the repeater: ....

No matter what I try, I always get error "CS1026: ) expected".

Could anyone point out what I am doing wrong?

Yes. You're not simplifying the problem.

This is a case where you should use what I call "binary destroy" (like
binary search, but more violent). Delete half of your ItemTemplate. See if
you still have the problem. If so, delete half of what remains and try
again. If not, put back what you deleted and delete half of it and try
again. You'll eventually find something you can remove and have things work,
or add back and have them fail. That's the culprit...
 
G

Guest

Not sure what the problem is yet, but I tried creating a new page with just a few things on it (including a repeater). It works like it should. However, on the old page with the same code it didn't work. Unfortunately, this is the second time I have had a problem with VS.NET (the first time was an extreme slow-down with a winforms app whenever a window was painted -- had to re-create the form to fix the problem)

If I find the problem I'll make sure to post what it is.
 

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,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top