Question : using Parameters.AddWithValue populated by QueryStringField

I have been using a SQL data source to popoulate a repeater control.
However now that I want to page the control the data is being created in a sub withn the VB script ( see old and new respectfully below).
what I want to do is populate the

SQLCmd.Parameters.AddWithValue("Brand", "") with the values I set in the sqldatasource



this means I need to bring back the string parameter Brand and ensure that ConvertEmptyStringToNull="false" .

I may also want to populat the parameter with SessionParameter or a drop down field value, if the solution is the same. I'm sure this should be easy but just can't work it out.

Cheers
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
=============== OLD sql datasource ==============



        
            
            
            
        

============ NEW data command ================

Dim connStr As String = ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString
        Dim con As SqlConnection = New SqlConnection(connStr)
        Dim SQLCmd As New SqlCommand("SPRepeaterProducts", con)
        SQLCmd.CommandType = CommandType.StoredProcedure 'Setup Command Type
        SQLCmd.Parameters.AddWithValue("Brand", "")
        SQLCmd.Parameters.AddWithValue("MinPrice", "0")
        SQLCmd.Parameters.AddWithValue("maxPrice", "160")
        SQLCmd.Connection.Open()

Answer : using Parameters.AddWithValue populated by QueryStringField

How is your page being resubmitted and how is querystring changed?
You can retriever querystring value like:

Dim brandValue As String = Request.QueryString("Brand")
'you can check for null here if you want
SQLCmd.Parameters.AddWithValue("Brand", brandvalue)

Similarly you can get values from Session or DropDownList.SelectedValue and simply pass the value to the AddWithValue method.

Hope I am understanding it right.
Random Solutions  
 
programming4us programming4us