Datalist problemo... please help..

son

Regular
Joined
Feb 21, 2004
Messages
67
hi
i have a datalist problem driving me nuts as usual.. hope someone can help... really would appreciate it..

i am using webforms...
i am using sql server as my backend and i am using the northwind database..
i have a dataset (name:dsorders) which is added to my webform (name:webform2).. i have also a datalist(name:dlstOrders) which is added to my form and i have set its properties in the properties window as follows:

datalist
property datasource - dsOrders.Tables("Orders").DefaultView

i have a dropdownlist on my form which is getting its values from a cached dataset which is on another webform(name:webform1)..anyways thats working fine... i have also a command button on my form (the webform2) which when i click it is suppose to allow me view in my datalist the record or records related to the value in the dropdownlist.. my code in my aspx.vb file is as follows

Visual Basic:
'declared on top of my class 

    Public adaptOrders As SqlDataAdapter
    Public dsorders As dsorders
    Public dsCustomers As New dsCustomers

'this works fine to populate my dropdownlist
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
       

        'get the cached variables
        adaptOrders = Cache("adaptOrders")
        dsorders = Cache("dsorders")
        dsCustomers = Cache("dsCustomers")

        'run the first time the page is loaded
        If Not IsPostBack Then


            'for each row in the table
            Dim dscustomers As New dsCustomers
            dscustomers = Cache("dsCustomers")

            Dim rownext As dsCustomers.CustomersRow
            For Each rownext In dscustomers.Customers()
                'create a new list item
                Dim lstNew As New ListItem

                lstNew.Text = rownext.CustomerID
                lstNew.Value = rownext.CustomerID
                ' add the list item to the drop-down list
                drpCustomer.Items.Add(lstNew)
            Next
            'select the first item in the list
            drpCustomer.SelectedIndex = 0

            'drpCustomer.DataBind()
        End If
    End Sub

'this aint working fine me getting error can not find column ex:[ALFKI]
 Private Sub butView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butView.Click
        'set the filter for the view to display
        Dim dsorders As New dsOrders

        dsorders.Tables("orders").DefaultView.RowFilter = "customerID=" + _
        drpCustomer.Selecteditem.value.ToString()
        'bind the datalist to the control
        dlstOrders.DataBind()

    End Sub

can someone please help.. i hope i explained it well - what me doing wrong... :confused:
 
First big problem I see is that you have a global variable named dsorders and in your butView_Click (should be btnView_Click) you have a variable with the same name, while this compiles and it works its bad practice.

Second... your butView_Click is getting the selected item from drpCustomer...is there a ALFK1 column?
 
hi thanks millions for your reply.. really really appreciated...
thanks

you asked me if is there a ALFK1 column? no its not its a primary key value in one of my columns that i have in my database customers table which is supposed to be also in my dscustomers dataset..

would appreciate your a reply.. been on this for far too long and its killing me.. thanks
 
Back
Top