Bind Data in Access to ASP:DataList (VB.net) : DataList « ASP.net Controls « ASP.NET Tutorial






<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
   sub Page_Load(Sender as Object, e as EventArgs) 
      dim objConn as new OleDbConnection( _
            "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
            & "DATA SOURCE=" _
            & Server.MapPath("EmployeeDatabase.mdb;"))
      dim objCmd as OleDbDataAdapter = new OleDbDataAdapter("select * from employee", objConn)
      dim ds as DataSet = new DataSet()
      objCmd.Fill(ds, "employee")
      MyDataList.DataSource = ds.Tables("employee").DefaultView
      MyDataList.DataBind()
    end sub
</script>

<html><body>
  <ASP:DataList id="MyDataList" RepeatColumns="2" 
     RepeatDirection="Vertical" runat="server">
     <ItemTemplate>
        <div style="padding:15,15,15,15;font-size:10pt;
           font-family:Verdana">
        <div style="font:12pt verdana;color:darkred">
           <i><b><%# DataBinder.Eval(Container.DataItem, "FirstName")%>&nbsp; 
           <%# DataBinder.Eval(Container.DataItem, "LastName")%>
           </i></b>
        </div>
        <br>
        <b>ID: </b><%# DataBinder.Eval(Container.DataItem, _
           "ID") %><br>
          </div>
      </ItemTemplate>
  </ASP:DataList>
</body></html>








3.39.DataList
3.39.1.Bind Data in Access to ASP:DataList (VB.net)
3.39.2.Set SelectedItemStyle, SelectedItemTemplate, ItemTemplate for asp:DataList (VB.net)
3.39.3.Use OnItemCommand, OnEditCommand, OnCancelCommand, OnUpdateCommand, OnDeleteCommand for asp:DataList (VB.net)
3.39.4.Table Data Binding