Datagrid/Parameter Challenge

R

Rick

How can I send multiple parameters in a query string. I'd like to use
one of the parameters to populate my datagrid. Once I get the
parameter how do I incorporate it into my select?

Here's the code with one parameter:
<TD vAlign="middle" align="right" width="100"><A
href='ProductsDetails.aspx?ProductID=<%#
DataBinder.Eval(Container.DataItem, "ProductID") %>'><IMG height=75
src='ProductImages/thumbs/<%# DataBinder.Eval(Container.DataItem,
"ProductImage") %>' width=100 border=0>

How do I add a second?
 
T

Thomas Dodds

did you try?

href='ProductsDetails.aspx?ProductID=<%#DataBinder.Eval(Container.DataItem,
"ProductID") %>&SecondVal=<%# DataBinder.Eval(Container.DataItem,"WHATEVER")
%>'
 
R

Rick Azoy

Thanks! That worked. So now I'm passing the modelnumber as a second
value. 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 ProductIDParam As New SqlClient.SqlParameter("@ProductID",
SqlDbType.Int, 4)
ProductIDParam.Value = "ProductID"
myCommand.Parameters.Add(ProductIDParam)

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top