The dynamicDropdowns + storeprocedure does not update correctly

The values from the dynamicDropdowns does not run my StoreProcedure co

Page 1 of 1

0 Replies - 1323 Views - Last Post: 18 February 2009 - 02:58 AM Rate Topic: -----

#1 micke  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 56
  • Joined: 25-August 08

The dynamicDropdowns + storeprocedure does not update correctly

Post icon  Posted 18 February 2009 - 02:58 AM

Hi,

After some rebuildning of the code i finally got the dynamic dropdowns to send in correct value.
(http://www.dreaminco...h...c=85625&hl= ) But the value i got from the dropdown does not select correct value in the storeProcedure.

Any sugestions?

files : Attached File  files.zip (7.63K)
Number of downloads: 49

background
----------
I create an table from the result of the storeprocedure : cmdTradeInGetOrder, and on each row i also create 1 dropdown and 2 labels (dynamic) and the dropdown are populated from the storeprocedure : cmdTradeInGetAssetByClient. so far is everything working. When i select an value from the dropdown the assetID (ID) is sent to the DropDown1_SelectedIndexChanged1 this is working since the ID and value is sent to the dynamic labels, and also to the

LabelWhatList.Text = aEquipmentName.ID
LabelWhatValue.Text = aEquipmentName.SelectedValue

the problem
-----------

The storeporcedure: cmdTradeInGetAssetByID seems only to generate the same result, since the dynamic labels got the same value...





 Protected Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        Dim aEquipmentName As DropDownList
        Dim aSerienummer As Label
        Dim aModel As Label

        Dim myTable As New Table
        Dim myRow As TableRow
        Dim myCell As TableCell

        Dim readAsset As SqlClient.SqlDataReader = Nothing          'readAsset
        Dim readTradeInRows As SqlClient.SqlDataReader = Nothing    'readTradeInRows

        Dim sResultClient As String = ""      
        Dim counter As Integer = 0
        Dim linkProd As HyperLink
        Dim sLevArtNr As String
        Dim objPortalInfo As New PortalInfo

       
        Try
            oDBLib.cmdTradeInGetOrder.Parameters("@orderID").Value = CType(Request.QueryString("OrderID"), System.Int32)
            oDBLib.cnnSEB.Open()

            readTradeInRows = oDBLib.cmdTradeInGetOrder.ExecuteReader()

            While readTradeInRows.Read

                If Not IsDBNull(readTradeInRows("isClient")) Then sResultClient = readTradeInRows("isClient").ToString()

                myRow = New TableRow
                myRow.CssClass = "tr5"

                'sLevArtNr
                myCell = New TableCell
                linkProd = New HyperLink
                myCell.CssClass = "td11"
                linkProd.Target = "_self"
                linkProd.ForeColor = Color.Black
                linkProd.NavigateUrl = "../../sales/produkt/ProductDetails.aspx?productId=" & readTradeInRows("ID")
                linkProd.Text = readTradeInRows("sLevArtNr")
                sLevArtNr = readTradeInRows("sLevArtNr")
                myCell.Controls.Add(linkProd)
                myRow.Cells.Add(myCell)

                'name
                myCell = New TableCell
                linkProd = New HyperLink
                myCell.CssClass = "td12"
                linkProd.NavigateUrl = "../../sales/produkt/ProductDetails.aspx?productId=" & readTradeInRows("ID")
                linkProd.Target = "_self"
                linkProd.Text = readTradeInRows("Namn")
                myCell.Controls.Add(linkProd)
                myRow.Cells.Add(myCell)

                'white cell
                myCell = New TableCell
                myCell.CssClass = "td13"
                myCell.Text = ""
                myRow.Cells.Add(myCell)


                ' *********************************************    CLIENT    *********************************************

                If sResultClient = "True" Then

                    Try
                        oDBLib2.cmdTradeInGetAssetByClient.Parameters("@userID").Value = 1000
                        oDBLib2.sqlConn.Open()

                        readAsset = oDBLib2.cmdTradeInGetAssetByClient.ExecuteReader()

                        If readAsset.HasRows Then

                            'aEquipmentName
                            myCell = New TableCell
                            If Not IsOdd(counter) Then
                                myCell.CssClass = "td14"
                            Else
                                myCell.CssClass = "td20"
                            End If
                            aEquipmentName = New DropDownList
                            With aEquipmentName
                                .ID = "aEquipmentName" + counter.ToString
                                .DataSource = readAsset
                                .DataValueField = "assetID"
                                .DataTextField = "EquipmentName"
                                .AutoPostBack = True
                                .DataBind()
                                .Width = 120
                            End With
                            aEquipmentName.Items.Insert(0, "please select")
                            AddHandler aEquipmentName.SelectedIndexChanged, AddressOf DropDown1_SelectedIndexChanged1
                            myCell.Controls.Add(aEquipmentName)
                            myRow.Cells.Add(myCell)
                            myTable.Rows.Add(myRow)

                            'serialnumber
                            myCell = New TableCell
                            If Not IsOdd(counter) Then
                                myCell.CssClass = "td15"
                            Else
                                myCell.CssClass = "td21"
                            End If
                            aSerienummer = New Label
                            With aSerienummer
                                .ID = "aSerienummer" + counter.ToString
                                .Text = ""
                            End With
                            myCell.Controls.Add(aSerienummer)
                            myRow.Cells.Add(myCell)

                            'model
                            myCell = New TableCell
                            If Not IsOdd(counter) Then
                                myCell.CssClass = "td16"
                            Else
                                myCell.CssClass = "td22"
                            End If
                            aModel = New Label
                            With aModel
                                .ID = "aModel" + counter.ToString
                                .Text = ""
                            End With
                            myCell.Controls.Add(aModel)
                            myRow.Cells.Add(myCell)

							' if no rows was found
                        Else

                            myCell = New TableCell
                            If Not IsOdd(counter) Then
                                myCell.CssClass = "td14"
                            Else
                                myCell.CssClass = "td20"
                            End If
                            aEquipmentName = New DropDownList
                            With aEquipmentName
                                .ID = "aEquipmentName" + counter.ToString
                                .Width = 120
                            End With
                            aEquipmentName.Items.Insert(0, "diden't find anything")
                            AddHandler aEquipmentName.SelectedIndexChanged, AddressOf DropDown1_SelectedIndexChanged1
                            myCell.Controls.Add(aEquipmentName)
                            myRow.Cells.Add(myCell)
                            myTable.Rows.Add(myRow)

                            readAsset.Close()
                            oDBLib2.sqlConn.Close()

                            'serialnumber
                            myCell = New TableCell
                            If Not IsOdd(counter) Then
                                myCell.CssClass = "td15"
                            Else
                                myCell.CssClass = "td21"
                            End If
                            aSerienummer = New Label
                            With aSerienummer
                                .ID = "aSerienummer" + counter.ToString
                                .Text = ""
                            End With
                            myCell.Controls.Add(aSerienummer)
                            myRow.Cells.Add(myCell)

                            'model
                            myCell = New TableCell
                            If Not IsOdd(counter) Then
                                myCell.CssClass = "td16"
                            Else
                                myCell.CssClass = "td22"
                            End If
                            aModel = New Label
                            With aModel
                                .ID = "aModel" + counter.ToString
                                .Text = ""
                            End With
                            myCell.Controls.Add(aModel)
                            myRow.Cells.Add(myCell)

                        End If

                        myTable.Rows.Add(myRow)


                    Catch Err As Exception
                        ' Handle an error by displaying the information.
                        lblInfo.Text = "<br /><br /><b>Error reading the database:</b> "
                        lblInfo.Text &= Err.Message

                    Finally
                        'close connection
                        readAsset.Close()
                        oDBLib2.sqlConn.Close()

                    End Try

                    sResultClient = ""
                End If
				
				
 Protected Sub DropDown1_SelectedIndexChanged1(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim aEquipmentName As DropDownList = sender
        Dim aSerienummer As Label = Me.FindControl(Replace(aEquipmentName.ID.ToString(), "aEquipmentName", "aSerienummer"))
        Dim aModel As Label = Me.FindControl(Replace(aEquipmentName.ID.ToString(), "aEquipmentName", "aModel"))
        Dim myProduct As New Product
        Dim readAsset As SqlClient.SqlDataReader = Nothing

        myProduct.ProductID = aEquipmentName.SelectedValue

        If aEquipmentName.SelectedIndex > 0 Then

            Try

                oDBLib2.cmdTradeInGetAssetByID.Parameters("@assetId").Value = CType(aEquipmentName.SelectedValue, System.Int32) '7851
                oDBLib2.sqlConn.Open()

                readAsset = oDBLib2.cmdTradeInGetAssetByID.ExecuteReader()

                If readAsset.Read Then

                    aSerienummer.Text = readAsset("SerialNumber")
                    aModel.Text = readAsset("namn")

                End If


            Catch Err As Exception
                ' Handle an error by displaying the information.
                lblInfo.Text = "<br /><br /><b>Error reading the database:</b> "
                lblInfo.Text &= Err.Message

            Finally
                'close connection
                readAsset.Close()
                oDBLib2.sqlConn.Close()

            End Try

        Else
            aSerienummer.Text = ""
            aModel.Text = ""
        End If

        LabelWhatList.Text = aEquipmentName.ID
        LabelWhatValue.Text = aEquipmentName.SelectedValue


    End Sub	


Is This A Good Question/Topic? 0
  • +

Page 1 of 1