Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Going to next page
Message
 
 
To
08/10/2009 18:40:44
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01427461
Message ID:
01428355
Views:
49
>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 replacing the < with # signs
>#%@ Page Language="VB" %>
>
>#!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>#script runat="server">
>
>    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
>        Me.GridView1.DataBind()
>    End Sub
>
>    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
>        e.Command.Parameters("Resource").Value = TextBox1.Text
>    End Sub
>#/script>
>
>#html xmlns="http://www.w3.org/1999/xhtml">
>#head runat="server">
>    #title>#/title>
>#/head>
>#body>
>    #form id="form1" runat="server">
>    #div>
>    
>        Enter the Parameter#br />
>        #asp:TextBox ID="TextBox1" runat="server">#/asp:TextBox>
>
>        #asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
>            Text="Get Data" />
>        #br />
>        #br />
>        #asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
>            DataSourceID="SqlDataSource1" AllowPaging="True">
>            #Columns>
>                #asp:BoundField DataField="idKPI_WOAgingValues" 
>                    HeaderText="idKPI_WOAgingValues" InsertVisible="False" 
>                    SortExpression="idKPI_WOAgingValues" />
>                #asp:BoundField DataField="IdParameter" HeaderText="IdParameter" 
>                    SortExpression="IdParameter" />
>                #asp:BoundField DataField="Value" HeaderText="Value" SortExpression="Value" />
>                #asp:BoundField DataField="SaveDate" HeaderText="SaveDate" 
>                    SortExpression="SaveDate" />
>            #/Columns>
>        #/asp:GridView>
>        #asp:SqlDataSource ID="SqlDataSource1" runat="server" 
>            ConnectionString="#%$ ConnectionStrings:MySqlConnection %>" 
>            ProviderName="#%$ ConnectionStrings:MySqlConnection.ProviderName %>" 
>            SelectCommand="select * from kpi_woagingvalues where idparameter = @resource">
>            #SelectParameters>
>               #asp:FormParameter Name="Resource" />
>            #/SelectParameters>
>        #/asp:SqlDataSource>
>        #br />
>        #br />
>    
>    #/div>
>    #/form>
>#/body>
>#/html>
>
>
>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
>
>.........Rich

1. Don't use FormParameter. You can use just Parameter or ControlParameter and set Textbox to be the ControlParameter name .

2. You need to add to your SQLDataSource definition OnSelecting = "SqlDataSource1_Selecting" if you want to set your parameter in the code behind. Right now your SQLDataSource doesn't have the event bind.

3. I think you need to add @ in front of the parameter's name in the Selecting event, e.g.
e.Command.Parameters("@Resource").Value = TextBox1.Text

BTW, are you using VS or typing your pages manually? Why do you have code behind inside the ASPX?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform