I have a UserControl inside a repeater. The repeater's datasource is from SQL Server.
User Control's .cs - MoviePanel.ascx.cs:
public int myMovieID { get; set; }
public string myMovieName { get; set; }
public string myMovieDescription { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
MovieIDLbl.Text = myMovieID.ToString();
MovieNameLbl.Text = myMovieName;
DescriptionLbl.Text = myMovieDescription;
}
ASPX Page:
<asp:Repeater ID="Repeater1" DataSourceID="ListOfMoviesDS" runat="server">
<ItemTemplate>
<uc1:MovieDetailPanel runat="server" myMovieID='<%# Eval("MovieID") %>'
myMovieName='<%# Eval("movieName") %>'
myMovieDescription='<%# Eval("movieDescription") %>'
id="MovieDetailPanel1" />
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("MovieID") %>'></asp:Label>
<asp:Label ID="Label2" runat="server"
Text='<%# Eval("movieName") %>'></asp:Label>
<asp:Label ID="Label3" runat="server"
Text='<%# Eval("movieDescription") %>'></asp:Label>
</ItemTemplate>
</asp:Repeater>
Here something very strange happens. The values are not getting passed to the UserControl. However, if I place Labels below the usercontrol and set text with Eval()
it works. You might think the usercontrol might be the problem. But if I manually type something, say in place of <%# Eval("movieName") %>
it gets passed to the user control and gets displayed.
I have NO CLUE! If the problem is with Eval() Labels should not get the text as well. Or if the problem is with the UserControl my manual text shouldn't get passed. I have no idea why Eval()'s values is not reaching the UserControl.
DataBinding
phase. – John Saunders