如何在asp.net?

时间:2015-11-19 13:08:15

标签: asp.net listview

我使用listview来显示来自mysql DB的表内容,这很好。但是我想知道如何在listview表的每一列中显示图像。

<LayoutTemplate>
<table runat="server" id="table1">

   <tr id="Tr1" runat="server">

     <th class="tablehead">
        Movie Name
    </th>
     <th class="tablehead">
        Movie Genre
    </th>
    <th class="tablehead">
        Image
    </th>
</table>
</LayoutTemplate>

 <ItemTemplate>
<tr id="Tr2" runat="server" class="tablerw">
 <td style="background-color:#EEEEEE;width:100px;" class="tablerw"> <asp:Label ID="Label5" runat="server"
   Text='<%#Eval("MovieName") %>' /></td>
 <td style="background-color:#EEEEEE;width:100px;"> <asp:Label ID="NameLabel" runat="server"
          Text='<%#Eval("movieGenre") %>' /></td>
    <td style="background-color:#EEEEEE;width:100px;"> <asp:Label ID="Label1" runat="server"
          Text='<%#Eval("Image") %>' /></td>
</tr>
</ItemTemplate>

Aspx.cs

public  DataTable GetAllmoviedet()
     {
        DataTable dt1 = new DataTable();
        try
         {
         string connString = cnst.cnstrin();
         string query = "SELECT `moviemaster`.`MovieName`,`moviemaster`.`image`,`moviemaster`.`MovieGenre`";
          MySqlDataAdapter ma = new MySqlDataAdapter(query, connString);
          DataSet DS = new DataSet();
          ma.Fill(dt1);
          return dt1;
        }
        catch (MySqlException e)
        {
            throw new Exception(e.Message);
        }
      }

protected void Page_Load(object sender, EventArgs e)
   {
    if (!Page.IsPostBack)
      {
        var tbl = GetAllmoviedet();
        ListView1.DataSource = tbl;
        ListView1.DataBind();
        GetAllmovie1();
     }
    }

通过使用这些代码,我可以设法只获取图像名称。所以我需要显示精确的图像而不是名称。我怎么可能这个?有什么帮助吗?

0 个答案:

没有答案
相关问题