E
Edgardo Rossetto
Hello there,
I have inserted a UserControl within a DataList:
/*------------------------------------------------------------*/
<asp
ataList ID="DataList1" runat="server" DataKeyField="ID"
DataSourceID="SqlDataSource1">
<ItemTemplate>
<uc1:WebUserControl ID="WebUserControl1" Title="My Title" runat="server" />
</ItemTemplate>
/*------------------------------------------------------------*/
The User Control is very simple, it only has a Literal control:
/*------------------------------------------------------------*/
public partial class WebUserControl : System.Web.UI.UserControl
{
string title = "Untitled";
public string Title
{
get
{
return title;
}
set
{
title = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
Literal1.Text = title;
}
}
/*------------------------------------------------------------*/
This works just fine, I see "My title" rendered for each Item in the
DataList, however:
/*------------------------------------------------------------*/
<asp
ataList ID="DataList1" runat="server" DataKeyField="ID"
DataSourceID="SqlDataSource1">
<ItemTemplate>
<uc1:WebUserControl ID="WebUserControl1" Title='<%# Eval("Title") %>'
runat="server" />
</ItemTemplate>
/*------------------------------------------------------------*/
This DOESN'T WORK!, all I get is "Untitled" (the default value)
I really don't get this behavior and its driving me nuts!
Any ideas?
Edgardo,
PS: I'm using VS 2005 Beta 2
I have inserted a UserControl within a DataList:
/*------------------------------------------------------------*/
<asp
DataSourceID="SqlDataSource1">
<ItemTemplate>
<uc1:WebUserControl ID="WebUserControl1" Title="My Title" runat="server" />
</ItemTemplate>
/*------------------------------------------------------------*/
The User Control is very simple, it only has a Literal control:
/*------------------------------------------------------------*/
public partial class WebUserControl : System.Web.UI.UserControl
{
string title = "Untitled";
public string Title
{
get
{
return title;
}
set
{
title = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
Literal1.Text = title;
}
}
/*------------------------------------------------------------*/
This works just fine, I see "My title" rendered for each Item in the
DataList, however:
/*------------------------------------------------------------*/
<asp
DataSourceID="SqlDataSource1">
<ItemTemplate>
<uc1:WebUserControl ID="WebUserControl1" Title='<%# Eval("Title") %>'
runat="server" />
</ItemTemplate>
/*------------------------------------------------------------*/
This DOESN'T WORK!, all I get is "Untitled" (the default value)
I really don't get this behavior and its driving me nuts!
Any ideas?
Edgardo,
PS: I'm using VS 2005 Beta 2