Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataRowView Issue with LINQ to SQL

Status
Not open for further replies.

majors479

Technical User
Jul 5, 2008
16
US
Good morning,

I have 2 cascading dropdownlists and am attempting to bind the child dropdownlist to the parent one. I found the following code online that should rectify my issue, but need assistance utilizing it, as I am using Linq to SQL data source.
Code:
Protected Sub ddlContact1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
        Dim ddl As DropDownList = CType(sender, DropDownList)
        Dim frmV As FormView = CType(ddl.NamingContainer, FormView)
        If Not frmV.DataItem Is Nothing Then
            Dim strCity As String = CType(frmV.DataItem, DataRowView)("contactcode")
            ddl.ClearSelection()
            Dim li As ListItem = ddl.Items.FindByValue(strCity)
            If Not li Is Nothing Then li.Selected = True
        End If
        'add an empty item title "make a selection"
        AddEmptyItem(ddl)

    End Sub

I receive an error at DataRowview, whch states "Type DataRowview is not defined"

Would anyone be so kind as to asssit me in replacing DataRovView.

Thanks so much

Sydney
 
You have to specify the namespace. I belive it is system.data. Or use the Imports statement:
Imports System.Data
 
Thanks for the assistance. Since I'm new to ASP.net I'm not exactly sure exactly how to use the Imports System.Data

When I have
Code:
Dim strCity As String = CType(frmV.DataItem, System.Data.DataRowView)("contactcode")

[\code]

I get this error "Unable to cast object of type 'tblICompany' to type 'System.Data.DataRowView'." 

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top