数据库内一字段内的多张图片路径如何输出到页面上,并能绑定到datalist上...
发布网友
发布时间:2024-11-04 21:25
我来回答
共3个回答
热心网友
时间:2024-11-04 22:14
代码页下下面方法
protected string getPP(string pp)
{
string[] a = pp.Split(';');
string x = string.Empty;
foreach (string k in a)
{
x += "<img src=\"" + k + "\" />";
}
return x;
}
datalist裏用个Literal如:
<asp:Literal ID="pp" runat="server" Text='<%# getPP(Eval("pp").ToString())%>' />
增加VB方法:
Protected Function getPP(ByVal pp As String)
Dim a As Array
a = pp.Split(";")
Dim x As String
x = String.Empty
Dim i As Int32
For i = 0 To a.Length - 1
x = x + "<img src=""" + a(i) + """ />"
Next
Return x
End Function
热心网友
时间:2024-11-04 22:09
字符串有Split方法,可以截取字符串
截取后保存为字符串数组
string s="\photo\001.jpg;\photo\002.jpg;\photo\003.jpg";
string[] sArray=s.Split(';') ;
热心网友
时间:2024-11-04 22:15
绑定是不好办了,只能写个小函数分割后输出吧