[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Can't access the selected index

rv

6/12/2002 11:56:00 AM

Hi.

I use ASP .Net with Mobile Internet Toolkit and I have a problem with a
selection list control :

When I dynamically fill the list at run time with either
the Add of the item as shown, or with a data binding with
an arraylist the selectionlist control returns a selection
property set to nothing and selectedindex property set to -
1, so I can't access my data.
(same probleme as Mike Harris, 05.28.2002 message)

Please help me.

Many thanks.

Herve



5 Answers

Julia Smit

6/13/2002 3:01:00 PM

0

I'm having the same problem..


For Each dataTableRowObj In dataTableObj.Rows()
Dim selectionListItem As New MobileControls.MobileListItem()
selectionListItem.Text = dataTableRowObj.Item("description").ToString()
selectionListItem.Value = dataTableRowObj.Item("ID").ToString()
selectionList.Items.Add(selectionListItem)
Next

Gives me a list with the values set from 0 till the number of elements.

I guess this is a bug??



"rv" <rv.c@caramail.com> wrote in message
news:OFVq5cfECHA.2344@tkmsftngp02...
> Hi.
>
> I use ASP .Net with Mobile Internet Toolkit and I have a problem with a
> selection list control :
>
> When I dynamically fill the list at run time with either
> the Add of the item as shown, or with a data binding with
> an arraylist the selectionlist control returns a selection
> property set to nothing and selectedindex property set to -
> 1, so I can't access my data.
> (same probleme as Mike Harris, 05.28.2002 message)
>
> Please help me.
>
> Many thanks.
>
> Herve
>
>
>


(Andres Sanabria)

6/13/2002 5:56:00 PM

0

Are you placing this code in the page load event?

AndresS

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.

Julia Smit

6/14/2002 7:45:00 AM

0

Yes indeed.


"Andres Sanabria" <AndresSONLINE@Microsoft.com> wrote in message
news:mCTBELvECHA.1560@cpmsftngxa07...
> Are you placing this code in the page load event?
>
> AndresS
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use. © 2002 Microsoft Corporation. All rights
> reserved.
>


rv

6/14/2002 10:44:00 AM

0


"Andres Sanabria" <AndresSONLINE@Microsoft.com> a écrit dans le message de
news: mCTBELvECHA.1560@cpmsftngxa07...
> Are you placing this code in the page load event?
>
> AndresS


Yes. Here is my code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim sConnectString As String = Session.Item("connect_string")
Dim oCon As New OleDb.OleDbConnection(sConnectString)
Dim sSQL As String

sSQL = "select lastname + ' ' + firstname as nom_complet, login from
owners order by lastname"

Dim oCom As New OleDb.OleDbCommand(sSQL, oCon)
oCom.Connection.Open()
Dim oReader As OleDb.OleDbDataReader = oCom.ExecuteReader()
list_owner.Items.Clear()

'Do While oReader.Read
'list_owner.Items.Add(oReader.Item("nom_complet").ToString())
'Loop

' The methode shown befor, OR the next one

' On peut remplir la Selection list en utilisant le data binding
list_owner.DataSource = oReader
list_owner.DataTextField = oReader.Item("nom_complet")
list_owner.DataValueField = oReader.Item("login")
list_owner.DataBind()

oReader.Close()
oCon.Close()

End Sub

Herve.


(Andres Sanabria)

7/13/2002 12:35:00 AM

0

okay...

you need to do the databind in the first request, not in everysingle
request. To address this issue in your page_loadd check to see if it is a
postback

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'new code
if (me.ispostback == false) then
' DO ALL THE DATABIND HERE
endif
en sub.

Hopes this helps

AndreS

this posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.