Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
I've got a listview, which holds a bitmap (imagebutton) and details of the video. When I load the page this list should populate. All the details of the video clip populates, but no image is displayed. I store the images and videos in a folder, and the path of the images in a sql database. How do populate the image in the imagebutton? This is what Ive done:

ASP.NET
<asp:ListView runat="server" ID="lvlist" >
   <LayoutTemplate>
   <div id="itemPlaceholder"  runat="server" />
   </LayoutTemplate>
   <ItemTemplate>
   <br />
   <div style="height:100px;">                                       
      <a href="PlayVideo.aspx?vid=<%# DataBinder.Eval(Container.DataItem, "ID") %>">
       <asp:ImageButton id="imgVidThumbnail" runat="server" AlternateText="Watch"
      ImageAlign="left" Width="150" Height="120px" style="margin-bottom:10px;  margin-left: 32px; margin-right:15px;" ImageUrl ='<%= ResolveClientUrl(Eval("ThumbPath"))%>'  CommandArgument='<%= ResolveClientUrl(Eval("ThumbPath"))%>'/>
        </a>
        <asp:Label ID="Label4" runat="server" Text="Title: " CssClass="ltrTitle" Width="100px" ></asp:Label>
         <asp:Label ID="ltrTitle" runat="server" Text='<%#Eval("FileTitle") %>' CssClass="ltrTitle" Width="300px" ></asp:Label>
         <br />
         <asp:Label ID="Label2" runat="server" Text="Date Uploaded: " CssClass="ltrTitle" Width="100px" ></asp:Label>
          <asp:Label ID="ltrDateUploaded" runat="server" Text='<%#Eval("DateUploaded") %>' CssClass="ltrTitle" Width="200px" ></asp:Label>
        <br />
        <asp:Label ID="Label3" runat="server" Text="Description: " CssClass="ltrTitle" Width="120px" ></asp:Label>
        <div id="div" style="overflow-x:auto; overflow-y:auto; width:75%; max-width:75%; height:55px; max-height:55px; word-break:break-all; background-color:ghostwhite;"  runat="server"> 
       <asp:Label ID="ltrDescription" runat="server" Text='<%#Eval("Description") %>' CssClass="ltrTitle" Width="75%" ></asp:Label>
      </div>
       </div>
       <br /> <br />
   </ItemTemplate>
 </asp:ListView>

C#
private void BindList()
       {
           SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RoadHogzConnectionString"].ConnectionString);
           con.Open();
           SqlCommand cmd = new SqlCommand("Select * from VideoInfo", con);
           cmd.ExecuteNonQuery();
           SqlDataAdapter adp = new SqlDataAdapter(cmd);
           DataSet ds = new DataSet();
           adp.Fill(ds, "Video");
           Session["videos"] = ds;
           lvlist.DataSource = GetVideoList("Select * FROM VideoInfo");
           lvlist.DataBind();
       }



The path will change from month to month.. the only part that will stay the same is uploads and the last folder: the folder path will be like \uploads\Year\Month\thumb - month and year will change every month and every year.....

EDIT:
In my view source on the browser it gives it gives me a different path: This line is used here: <img runat="server" src='<%= ResolveClientUrl(Eval("ThumbPath"))%>' />
C#
<a href="PlayVideo.aspx?vid=1038">
                                  <input type="image" name="ctl00$MainContent$lvlist$ctrl1$imgVidThumbnail" id="MainContent_lvlist_imgVidThumbnail_1" src="<%=%20ResolveClientUrl(Eval("ThumbPath"))%>" alt="Watch" align="left" style="height:120px;width:150px;margin-bottom:10px;  margin-left: 32px; margin-right:15px;" />
                                           </a>


This line : <img runat="server" ImageUrl='<%#Eval("ThumbPath") %>' /> gives me the correct path which is stored in db....
Posted
Updated 4-Jun-13 3:29am
v7
Comments
Mahesh Bailwal 4-Jun-13 7:34am    
Can you check in view source of page in browser what path of the image?
link_that 4-Jun-13 7:59am    
Hi Mahesh, No I don't see any path displayed?
Mahesh Bailwal 4-Jun-13 8:03am    
Can you share your view source and ResolveClientUrl method code?
link_that 4-Jun-13 8:24am    
When I check in view source it gives me this path with other characters... I will update on my post to add it to a codeblock... the characters may be the problem but how do I get rid of it or correct it?

1 solution

Saving the path as a virtual path without server mappath. ~/.. instead of c:/, The rest of the code works fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900