title: How to show images in a datalist?
body: <p>Can anyone help me in displaying the images in a datalist? Here is my HTML:</p>
  
  <pre><code>&lt;td valign="top" align="center"&gt;
  &lt;asp:DataList ID="SearchResultList" runat="server" Width="100%" 
      RepeatColumns="5" Height="141px"&gt;
      &lt;ItemTemplate&gt;
          &lt;table border="0" cellpadding="2" cellspacing="2" align="center" style="background-color: #f5f5f5"&gt;
              &lt;tr&gt;
                  &lt;td align="center" valign="top"&gt;
                     &lt;a href='&lt;%#getHREF(Container.DataItem)%&gt;'&gt;
                        &lt;asp:Image ID="Image" runat="server" ImageUrl='&lt;%#getSRC(Container.DataItem)%&gt;' /&gt;
                      &lt;/a&gt;
                  &amp;nbsp;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is my code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!Page.IsPostBack)
      {
          GetSearchResult(Request.QueryString["SearchText"].ToString());
      }
  }
  
  public void GetSearchResult(string searchText)
  {
      string GetSearchResult = "Select Name,Image FROM [PMB_User] where Name like '" + searchText + "%'";
  
      //ds = UHclass.ConnectDataBaseReturnDS(GetSearchResult);
      dt = UHclass.ConnectDataBaseReturnDT(GetSearchResult);
  
      if (dt.Rows.Count &gt; 0)
      {
          GridView1.DataSource = dt;
          GridView1.DataBind();
          SearchResultList.DataSource = dt;
          SearchResultList.DataBind();
      }
  }
  
  public string getHREF(object sURL)
  {
      DataRowView dRView = (DataRowView)sURL;
      string Id = dRView["Name"].ToString();
      return ResolveUrl("~/Userpage.aspx?Name=" + Id);
  }
  
  public string getSRC(object imgSRC)
  {
      DataRowView dRView = (DataRowView)imgSRC;
      string ImageName = dRView["Image"].ToString();
      if (ImageName == "NoImage")
      {
          return ResolveUrl(@"~/UserImage");
      }
      else
      {
          return ResolveUrl("~/UserImage/" + dRView["Image"].ToString());
      }
  }
  }
  </code></pre>
  
  <p>I'm able to fetch the data but not able to display in a datalist.</p>