create table StudentMaster (studID int, studName varchar(50), DOB date, Percentage float, courseName varchar(20), Address varchar(100))
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Configuration" %>
<script language="VB" runat="server" Debug="true">
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindData()
End If
End Sub
Sub BindData()
Dim constr As String = ConfigurationSettings.AppSettings("ConnectionString")
Using oConn As New SqlConnection(constr)
Dim cmd As New SqlCommand("select * from StudentMaster")
Dim sda As New SqlDataAdapter()
cmd.Connection = oConn
sda.SelectCommand = cmd
Dim dt As New DataTable()
sda.Fill(dt)
FormView1.DataSource = dt
formview1.DataBind()
detailview.DataSource = dt
detailview.DataBind()
End Using
End Sub
</script>
<body>
<form id="form1" runat="server">
<div>
<h2><i><u>Record to DetailView Control</u></i></h2>
<asp:DetailsView ID="detailview" runat="server" Width="275px">
</asp:DetailsView>
<h2><i><u>Record to FormView Control</u></i></h2>
<asp:FormView ID="formview1" runat="server" AutoGenerateColumns="false" AllowPaging ="true">
<ItemTemplate>
<b><%#Eval("studName")%></b>  
<b><%#Eval("DOB", "{0:MM/dd/yyyy}")%></b>  
<b><%#Eval("courseName")%></b>  
<b><%#Eval("Address")%></b>
</ItemTemplate>
</asp:FormView>
</div>
</form>
</body>
</html>