0

I had receive the above mention error I have load printer info in first combo box and when select value a event triggered and load values in second combo box using printer info but i am receiving subject mention error.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'txtUPCode.Attributes.Add("onclick", "showDiv('divQtyAddSidebar');")
        'txtUPCode.Attributes.Add("onfocus", "showDiv('divQtyAddSidebar');")
        'txtUPCode.Attributes.Add("onblur", "hideDiv('divQtyAddSidebar', this.value);")

        txtProductSearch.Attributes.Add("onfocus", "showDiv('divSearchSidebar');")
        txtProductSearch.Attributes.Add("onblur", "hideDiv('divSearchSidebar', this.value);")



        If Not IsPostBack Then
            ''Load Brand Name
            ddlSelectBrand.DataSource = wseCommerce.LoadBrand().Tables(0)
            ddlSelectBrand.DataTextField = wseCommerce.LoadBrand().Tables(0).Columns("ManufacturerName").ColumnName.ToString()
            ddlSelectBrand.DataValueField = wseCommerce.LoadBrand().Tables(0).Columns("ManufacturerCode").ColumnName.ToString()
            ddlSelectBrand.DataBind()
        End If

        LoadPageStateFromPersistenceMedium()
    End Sub

    Protected Sub ddlSelectBrand_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSelectBrand.SelectedIndexChanged
        If ddlSelectBrand.SelectedValue <> "" Then
            ddlSelectCatridge.Enabled = True
            ddlSelectPrinter.Enabled = True

            'Load Printer against Brand Name
            Dim BrandName As String = ddlSelectBrand.SelectedItem.Text.ToString
            [B]ddlSelectPrinter.DataSource = wseCommerce.LoadPrinter(BrandName).Tables(0)[/B] 'error Object reference not set to an instance of an object. 
            ddlSelectPrinter.DataValueField = wseCommerce.LoadPrinter(BrandName).Tables(0).Columns("PrinterName").ColumnName.ToString()
            ddlSelectPrinter.DataTextField = wseCommerce.LoadPrinter(BrandName).Tables(0).Columns("PrinterName").ColumnName.ToString()
            ddlSelectPrinter.DataBind()
        Else
            ddlSelectCatridge.Enabled = False
            ddlSelectPrinter.Enabled = False
        End If
    End Sub
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rohand
0

Try to remove .ToString from:

'Load Printer against Brand Name
Dim BrandName As String = ddlSelectBrand.SelectedItem.Text.ToString
0

I don't think ToString() is the problem..
You just make sure that your ddlSelectBrand.SelectedItem.Text retrurn BrandName. If it's returning the BrnadName than debugg the wseCommerce.LoadPrinter(BrandName).Tables(0) method and make sure it returns the DataSet.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.