通过C#在DataList模板中添加图像控件

时间:2012-09-18 16:51:03

标签: c# asp.net .net datalist

我想通过C#在datalist Itemtemplate中插入asp图像控件。以下是我目前正在尝试的代码,但它没有用。

DataList DataListCampaign = new DataList();
DataListCampaign.RepeatLayout = RepeatLayout.Flow ;
DataListCampaign.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
DataListCampaign.DataSource = CampTabImage;
DataListCampaign.DataBind();
Image TabImages = new Image();
TabImages.ID = "TabImages";
DataListCampaign.Controls.Add(TabImages);
TabContainer1.Tabs[k].Controls.Add(DataListCampaign);

问题在哪里?

2 个答案:

答案 0 :(得分:0)

查看此link ...我相信它会让您在实现目标方面取得进展。

答案 1 :(得分:0)

试试这个

     Image TabImages = new Image();
     TabImages.ID = "TabImages";
     TabImages.ImageUrl = "~/imagepath";
     DataListCampaign.Items[0].Controls.Add(TabImages);