Load data from Access database to Mobile:List : List « Mobile « ASP.NET Tutorial






<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="VB" %>
<%@ Register TagPrefix="Mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script 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 new OleDbDataAdapter _
         ("select * from employee", objConn)

      dim ds as DataSet = new DataSet()
      objCmd.Fill(ds, "employee")

      lNames.DataSource = ds.Tables("employee").DefaultView
      lNames.DataBind()
   end sub
   
   sub NamePick(Sender as Object, e as ListCommandEventArgs)
      lblName.Text = e.ListItem.Text
      lblPhone.Text = e.ListItem.Value
      ActiveForm = frmPrice
   end Sub
</script>

<Mobile:Form id="frmMenu" BackColor="#ccddcc" 
   runat="server">  
   <Mobile:Label runat="server" StyleReference="title" 
      Text="Names" />
   <Mobile:List id="lNames" runat="server" 
      OnItemCommand="NamePick" 
      DataTextField="FirstName"
      DataValueField="FirstName" />
</Mobile:Form>

<Mobile:Form id="frmPrice" BackColor="#ccddcc" 
   runat="server">
    <Mobile:Label id="lblName" runat="server"/>
    <Mobile:Label id="lblPhone" runat="server"/>
</Mobile:Form>








23.5.List
23.5.1.Pick List
23.5.2.Mobile:Label and Mobile:List
23.5.3.Load data from Access database to Mobile:List
23.5.4.Mobile List data binding