我想從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