Posts

Showing posts with the label Datalist Image

Datalist Image

Was once wondering how to get images from the database and display it in a datalist control or a datagrid control in ASP.NET, and came across the following probable solution (alternate ideas on this would be appreciated ).

Steps:

1.Get the image from the database and store it temporarily on the server side.
2.Set the ImageUrl property of the Image control to the temporary path.

Coding goes something like this,

aspx Page:

Datalist control included a image control and a label control to hold description.


<asp:DataList ID="DataList1" runat="server" >
        <ItemTemplate>
            <asp:Image ID="Image1" runat="server" Width="50" Height="50"/>
            <asp:Label ID="Label1" runat="server" ></asp:Label>
        </ItemTemplate>
</asp:DataList>

now when binding the grid to the database,

it would have been straightforward if at all path of the image was stored in the data…