Mobile SelectionList

Hi, I am new to asp.net programming. I am writing in ASP.Net and VB.NET.

I am writing a web based program for the Symbol MC50 (Windows 2003 Mobile 2nd Edition). The program works fine from vs2005 on my laptop.

I am having problems with SelectionList showing entries. I need to obtain the data from an existing database. I need the selection lists through the program to select user, then to select items.

If I use the following code it works on the MC50.

<mobile:Form id="Form1" runat="server">

<mobile:Label ID="Label2" Runat="server">Username:</mobile:Label>

<mobile:SelectionList
ID="List1" Runat="server">
<Item Text ="John"/>
<Item Text ="Peter"/>
<Item Text ="Henry"/>
</mobile:SelectionList>

<mobile:Label ID="Label3" Runat="server">Password:</mobile:Label>

<mobile:TextBox ID="txtPassword" Runat="server" Alignment="Left" Password="True"></mobile:TextBox>

<mobile:Command ID="btnAccept" Runat="server">Accept</mobile:Command>

</mobile:Form>

If I gather the data from a database as follows - it does not show the list:

<mobile:Form id="Form1" runat="server">

<mobile:Label ID="Label2" Runat="server">Username:</mobile:Label>

<mobile:SelectionList ID="List1" Runat="server"></mobile:SelectionList>

<mobile:Label ID="Label3" Runat="server">Password:</mobile:Label>

<mobile:TextBox ID="txtPassword" Runat="server" Alignment="Left" Password="True"></mobile:TextBox>

<mobile:Command ID="btnAccept" Runat="server">Accept</mobile:Command>

</mobile:Form>

Sub Form1_Init

connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|datadirectory|data.mdb;")

connection.Open()

myData = New OleDbDataAdapter("select staff_name from qrystaffmast", connection)

rs = New DataSet()

myData.Fill(rs, "Staff")

List1.DataSource = rs.Tables("Staff").DefaultView
List1.DataTextField = "staff_name"
List1.DataBind()

End Sub

And even if I do as follows it still does not work:

Sub Form1_Init

List1.Items.Add("Daryl")
List1.Items.Add("Peter")
List1.Items.Add("John")
List1.Items.Add("Mary")
List1.Items.Add("Joan")
End Sub

Does anyone know how to overcome this?

You need to initialize the last after the load event, not during the event init.

Joel Johnson

Syndicate content