Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Going to next page
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01427461
Message ID:
01428450
Vues:
48
>Revisiting this again and still in desperate need of help. I'm working with a different table and looking to get data based on a numeric field. Here is the entire code in my aspx page (modified only by removing the   tokens and

>In this version, the grid never appears. Entering a number in the textbox and pressing the button adds nothing to the screen (but I can see some refreshing going on in the status bar at the bottom.
>
>It seems this ought to be trivial but I can't even seem to get properly started. Any and all help greatly appreciated
>

Part of the problem is that the field you are trying to filter on is numeric but you haven't specified that anywhere. Assuming it's an integer, you could change your code like this:

Change your Selecting method to convert the textbox value to a numeric value (you have to use the @ in front of the parameter):
    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
        Dim filter As Integer
        If IsNumeric(TextBox1.Text) Then
            filter = Convert.ToInt32(TextBox1.Text)
        Else
            filter = 0
        End If
        
        e.Command.Parameters("@Resource").Value = filter
    End Sub
In the original code I showed using the form variable syntax. Honestly, if you're populating it directly you can just use a SelectParameter. So your SQlDataSource would look something like this - notice we're specifying the underlying type of the database field:
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MySqlConnection %" 
            ProviderName="<%$ ConnectionStrings:MySqlConnection.ProviderName %" 
            SelectCommand="select * from store where iid = @Resource"
            <SelectParameters
                <asp:Parameter DbType="Int32" DefaultValue="0" Name="Resource" /
            </SelectParameters
        </asp:SqlDataSource
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform