Populating a Datagrid from a URL Query string

Discussion in 'ASP .Net Datagrid Control' started by Rick Azoy, Aug 8, 2004.

  1. Rick Azoy

    Rick Azoy Guest

    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()





    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Rick Azoy, Aug 8, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon paugh
    Replies:
    1
    Views:
    753
  2. Replies:
    6
    Views:
    6,185
  3. Just D.
    Replies:
    0
    Views:
    443
    Just D.
    Aug 11, 2004
  4. ~greg
    Replies:
    5
    Views:
    136
    ~greg
    Apr 27, 2005
  5. nick
    Replies:
    1
    Views:
    461
    David Mark
    Feb 13, 2011
Loading...

Share This Page