Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get Item.Count after changing SQL select
Message
De
09/09/2010 11:15:02
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Get Item.Count after changing SQL select
Divers
Thread ID:
01480686
Message ID:
01480686
Vues:
92
Hello Everybody.

I am now working on a simple Intranet site. I thought I try myself in a .NET/ASP version (VS 2010) which is completely new to me - my heart really belongs to VFP.

I have on the asp page a listbox control which needs to update as the value in a textbox changes (currently I activate this whole process through a button click). Once the listbox is re-populated i need to complete some more action based on the new first item in the listbox - if there is anything, if not then do something else.

So, my problem is that once i have updated the select statement, the VB.NET code needs to get the new item count for the list in order to see if there is anything we need to do, but ofcourse that property (count) has not been updated yet because it is sitting on the client side.

How do you do this correctly - am I going about this totally the wrong way - or what am I missing here?

the following would not be accepted by UT as code, so I am changing the asp less then to ()
ASP.NET Code
                    (asp:ListBox 
                        ID="ListBox1" 
                        runat="server" 
                        DataSourceID="SqlDataSource1" 
                        DataTextField="ResultField" 
                        DataValueField="DocLocation" 
                        Height="207px"
                        Width="433px" AutoPostBack="True")
                    (/asp:ListBox)
                    (asp:SqlDataSource 
                        ID="SqlDataSource1" 
                        runat="server" 
                        ConnectionString="(%$ ConnectionStrings:DMSConnectionString2 %)" 
                        SelectCommand="select *, Patient_Last as ResultField from master"
                        ProviderName="(%$ ConnectionStrings:DMSConnectionString2.ProviderName %)")
                    (/asp:SqlDataSource)
VB.NET Code
        ' without this we get an error for a wrong value on SelectedIndex
        Me.ListBox1.SelectedIndex = -1
        'Me.ListBox1.ClearSelection()
        Me.ListBox1.Items.Clear()

        ' submit the new query
         Me.SqlDataSource1.SelectCommand = c_SelectStr

         If Me.ListBox1.Items.Count > 0 Then
            Me.ListBox1.SelectedIndex = 0
            Me.ListBox1_SelectedIndexChanged(Me.ListBox1, Nothing)
        Else
            ' clear the list
            'Me.ListBox1.SelectedIndex = -1
            'Me.ListBox1.ClearSelection()
            'Me.ListBox1.Items.Clear()
            Me.ListBox1_SelectedIndexChanged(Me.ListBox1, Nothing)
        End If
When I check Me.ListBox1.Items.Count it always returns 0. I am thinking because the server code (vb.net) has not completed yet and the client has not been updated.

How do you do this correctly?

Any help is greatly appreciated.
Thanks
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform