我想用datalist显示图片,可是怎么显示不出来呀1.<asp:DataList id="MyDataList" style="Z-INDEX: 101; LEFT: 80px; POSITION: absolute; TOP: 160px"
runat="server" RepeatColumns="3" Width="448px" Height="112px">
<ItemTemplate>
<IMG width=100 height=100 alt="" src='<%#DataBinder.Eval(Container,"DataItem.image")%>"'>
<%#DataBinder.Eval(Container.DataItem,"imagename")%>
<%#DataBinder.Eval(Container.DataItem,"imagedate")%>
</ItemTemplate>
</asp:DataList>2.if(!IsPostBack)
{
string conn=ConfigurationSettings.AppSettings["dsn"];
SqlConnection myConnection = new SqlConnection("conn");
// Connect to the SQL database using a SQL SELECT query to get all 
// the data from the "Titles" table.
SqlDataAdapter myCommand = new SqlDataAdapter("select top 9 from image order by imagedate", myConnection);
// Create and fill a DataSet.
DataSet ds = new DataSet();
myCommand.Fill(ds);
// Bind MyDataList to the DataSet. MyDataList is the ID for 
// the DataList control in the HTML section of the page.
MyDataList.DataSource = ds;
MyDataList.DataBind();
                                     }

解决方案 »

  1.   

    是不是我这 <IMG width=100 height=100 alt="" src='<%#DataBinder.Eval(Container,"DataItem.image")%>"'>有问题,是绑定的问题吗?
      

  2.   

    我想显示最新图片的前9张,datalist分了三列
      

  3.   

    src='<%#DataBinder.Eval(Container,"DataItem.image")%>"?能不能说明白一点?
      

  4.   

    不知道chaobeyond会不会在来?不过先谢谢你
      

  5.   

    如果你数据库里面存放的是图片的相对或绝对路径,可以使用<img src=...>来显示图片,或者更详细地说,你要将图片绑定到image控件里面去.
    如果你的数据库里面存放的是图片的二进制数据,这个就比起上面的来要复杂一点,你需要一个中间过程,将二进制数据转化为图片.比较典型的就是新建一个输入类型为流的aspx文件,直接从此文件中将二进制数据转化为图片,并输入.而datagrid里面的image控件将显示此图片.
    如:datagrid里面的image控件的绑定数据为: image.aspx?id=数据库中图片的编号而image.aspx将根据传递来的ID参数从数据库里获取二进制数据还原成图片将输入流.
      

  6.   

    我根据sxlfybb你的方法去做了,现在能显示,可是那排版问题确实很难看呀,有没有什么好办法呀