62,046
社区成员
发帖
与我相关
我的任务
分享
string path=数据库里读出来的路径字符串;
string[] paths=path.split(',');
for(int i=0;i<paths.Count;i++)
{
Image img=new Image();
img.ImageUrl=paths[i];
DIV1.Controls.Add(img);
}
foreach (DataListItem dl in DataList1.Items)
{
DropDownList ddl = (DropDownList)dl.FindControl("DropDownList1");
DropDownList ddl2 = (DropDownList)dl.FindControl("DropDownList2");
ddl.DataSource = SupplyTimestr.Dtimestr.Split(',');
ddl.DataBind();
ddl2.DataSource = SupplyTimestr.Dtimestr.Split(',');
ddl2.DataBind();
}
protected string GetUrl(string path)
{
path = path.Replace("~", "");
string url = @"http://" + HttpContext.Current.Request.Url.Host;
if (HttpContext.Current.Request.Url.IsLoopback)
url += ":" + HttpContext.Current.Request.Url.Port;
if (HttpContext.Current.Request.ApplicationPath == "/")
{
return url + path;
}
else
{
return url + HttpContext.Current.Request.ApplicationPath + path;
}
}
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<img src = '<%#GetUrl(Eval("imgPath").ToString())%>' />
</ItemTemplate>
</asp:DataList>
try
{
string newsId = Request.QueryString["Photo_NewsId"] == null ? "" : Request.QueryString["Photo_NewsId"];
if (newsId != "")
{
photo.Photo_NewsId = Convert.ToString(newsId);
//photo.Bind_News();
photo.Bind_Newsbrow();
this.lab_title.Text = photo.Photo_Title;
this.lab_date.Text = Convert.ToDateTime(photo.NewsDate).ToString();
DataList1.DataSource = photo.Bind_Newsbrow().DefaultView;
DataList1.DataBind();
DataList1.DataKeyField = photo.Photo_NewsId;
string str = photo.Photo_Url;
string[] sArray = str.Split(',');
}
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "error", "<script>alert('"+ex.Message+"')</script>");
}
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<div id="img" style="text-align:center;"><asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Photo_Url").ToString() %>' /></div>
<asp:Literal ID="Literal1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Photo_Content").ToString() %>'></asp:Literal>
</ItemTemplate>
</asp:DataList>