listview
からに動的な情報を渡したいのですUserControl
が、何かが足りないと思います。
.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 codebehindファイル:
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;
}
Imが次のような文字列テキストから値を取得しようとすると、すべてが正常に機能します。
<uc1:Info Name_Lbl="Name" Description_Lbl="Description" ID="info1" runat="server" />
しかし、から値を取得しようとするとDatasource
、usercontrolの文字列値は「null」になります。誰かが私が間違っていることを確認できますか?ありがとう、ジムオーク