<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server" language="VB">
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
BindData()
End If
End Sub
Sub BindData()
Const strConnString as String = "server=localhost;uid=sa;pwd=;database=pubs"
Dim objConn as New SqlConnection(strConnString)
Const strSQL as String = "SELECT * FROM titles"
Dim objCmd as New SqlCommand(strSQL, objConn)
objConn.Open()
dlTitles.DataSource = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
dlTitles.DataBind()
objConn.Close()
End Sub
Sub dlTitles_ItemCommand(sender as Object, e as DataListCommandEventArgs)
If e.CommandName = "Details" then
End If
End Sub
</script>
<form runat="server">
<asp:DataList runat="server" id="dlTitles"
OnItemCommand="dlTitles_ItemCommand">
<ItemTemplate>
<b>Title:</b> <%# DataBinder.Eval(Container.DataItem, "title") %>
<br />
[<asp:LinkButton runat="server" id="btnDetails"
Text="View Book Details" CommandName="Details" />]
</ItemTemplate>
<SeparatorTemplate>
<hr>
</SeparatorTemplate>
</asp:DataList>
</form>
|