Data binding with a repeater

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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...
 
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.
 
Back
Top