我想从listview
一些动态信息传递给UserControl
里面,但我想我失去了一些东西。传递变量用户控件列表视图(asp.net,C#)
.aspx页面中:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource"
DataKeyNames="id_Image">
<ItemTemplate>
<uc1:Info Name_Lbl='<%# Bind("Name") %>' Description_Lbl='<%# Bind("Description")%>' ID="info1" runat="server" />
</ItemTemplate>
</asp:ListView>
.ascx文件:
Name:
<asp:Label ID="NameLabel" runat="server" />
Description:
<asp:Label ID="DescriptionLabel" runat="server" />
的.ascx代码隐藏文件:
public string Name_Lbl { get; set; }
public string Description_Lbl { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
NameLabel.Text = Name_Lbl;
DescriptionLabel.Text = Description_Lbl;
}
一切工作正常,如果我试着去得到字符串值文字,如:
<uc1:Info Name_Lbl="Name" Description_Lbl="Description" ID="info1" runat="server" />
但是,当我试图从Datasource
获得值时,usercontrol中的字符串值为“null” 任何人都可以看到我在做什么错了吗?谢谢你,吉姆·橡树
谢谢。我有完全相同的问题。 – Pitarou 2013-05-23 14:00:52