Thursday, 8 December 2016

Showing uploaded images in data grid using vb.net

Hi all,

See the code below. Important code is highlighted in blue.
-----------------------------------------

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Main.aspx.vb" Inherits="Main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Welcome to Admin Home
    </div>
 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [Name], [Rollno], [filepath] FROM [tblReg]" >
        </asp:SqlDataSource>
 
    <br />
    <br />
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Rollno" HeaderText="Rollno"
                SortExpression="Rollno" />
           <asp:ImageField DataImageUrlField="filepath" ControlStyle-Width="100"
        ControlStyle-Height = "100" HeaderText = "Preview Image"/>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource>
    <br />
    </form>
</body>
</html>


Table structure and sample data




No comments:

Post a Comment