データベースからレシピ名を取得し、そのデータをリスト形式で表示する必要があります。私はコードを追加しました。しかし、テンプレートには何を含めるべきですか?ListView - >コードでデータを表示
ソース
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
</ItemTemplate>
</asp:ListView>
コード
protected void Page_Load(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection("Server=localhost;Database=FreedomKitchen;Uid=root;Password=;");
con.Open();
MySqlCommand cmd = new MySqlCommand("select Recipe_Name from Recipes", con);
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "Recipe_Names");
ListView1.DataSource = ds;
ListView1.DataBind();
}
こんにちは、私は、詳細が表示されますされ、リスト項目は次のページへのリンクのようになりたい必要がありますレシピのビュー。だから、これは望ましい実装ですか?ボタンは機能しますか?これでアイテムリスナーを実装する方法は?ありがとう – user6302221