ASP.Net/Mobile Control/Data Binding — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:52, 26 мая 2010
Bind data from Access database to mobile list (VB.net)
<source lang="csharp">
<%@ 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" language="VB"> Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet DBConn = New OleDbConnection( _ "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _ & "DATA SOURCE=" _ & Server.MapPath("EmployeeDatabase.mdb;")) DBCommand = New OleDbDataAdapter _ ("Select FirstName " _ & "From Employee " _ & "Order By FirstName", DBConn) DBCommand.Fill(DSPageData, _ "Employee") List1.DataSource = _ DSPageData.Tables("Employee").DefaultView List1.DataBind()
End Sub</script> <mobile:form
id="StartForm" runat="server">
<mobile:list
runat="server" id="list1" datatextfield="FirstName"
/> </mobile:form>
</source>
<source lang="csharp">
<%@ 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" language="VB"> Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet DBConn = New OleDbConnection( _ "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _ & "DATA SOURCE=" _ & Server.MapPath("EmployeeDatabase.mdb;")) DBCommand = New OleDbDataAdapter _ ("Select * " _ & "From Employee " _ & "Order By FirstName", DBConn) DBCommand.Fill(DSPageData, _ "Emps") ObjectList1.DataSource = _ DSPageData.Tables("Emps").DefaultView ObjectList1.DataBind()
End Sub</script> <mobile:form
id="StartForm" runat="server">
<mobile:objectlist
runat="server" id="ObjectList1" autogeneratefields="False" backcommandtext="Return to List"
>
<field name="EmpName" datafield="FirstName" title="Name"/> <field name="EmpPhone" datafield="LastName" title="Phone"/> <field name="EmpEmail" datafield="ID" title="Email"/>
</mobile:objectlist> </mobile:form>
</source>
<A href="http://www.nfex.ru/Code/ASPDownload/EmployeeDatabase.zip">EmployeeDatabase.zip( 10 k)</a>