Populating a Datagrid from a URL Query string

R

Rick Azoy

I'm passing the modelnumber as a second value in a query string. How do
I take that value now on the product details page to populate the
datagrid. Here's what I have now:

Dim ProductID As Integer = CInt(Request.Params("ProductID"))

Dim ModelNo As Integer = CInt(Request.Params("ModelNumber"))

' Obtain Product Details
Dim products As ASPNET.StarterKit.Commerce.ProductsDB = New
ASPNET.StarterKit.Commerce.ProductsDB

Dim myProductDetails As ASPNET.StarterKit.Commerce.ProductDetails =
products.GetProductDetails(ProductID)


Dim strSQL As String
strSQL = "SELECT * FROM CMRC_Products WHERE ModelNumber =
ModelNo ORDER BY ProductID"

''Set the datagrid's datasource to the datareader and databind
Dim myConnection As New
SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connectionStr
ing"))

Dim myCommand As SqlClient.SqlCommand = New
SqlClient.SqlCommand(strSQL, myConnection)

Dim ModelNoParam As New SqlClient.SqlParameter("@ModelNumber",
SqlDbType.Int, 4)
ModelNoParam.Value = "ModelNo"
myCommand.Parameters.Add(ModelNoParam)

myConnection.Open()
Datalist.DataSource = myCommand.ExecuteReader()
Datalist.DataBind()
myConnection.Close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top