Casting Problem DataQuery to DataTable

Antiflag

New member
Joined
Oct 14, 2009
Messages
2
Programming Experience
Beginner
Hi,
i have a problem using linq to show the data in the gridview...

Error:Unable to cast object of type 'System.Data.Linq.DataQuery`1[DataEntry.CRFORM]' to type 'System.Data.DataTable'.

i will post the code below,
there is a checkbox named Complete which on being checked should should the respective data in the gridview...

If (chkStatus.SelectedValue = "Complete") Then

Dim ds As New DataSet()

Dim Completedata = (From comdata In db.CRFORMs _
Where comdata.INCOMPLETE = "N" _
Select comdata)

Dim converteddata As System.Linq.IQueryable = Nothing
converteddata = DirectCast(Completedata, System.Data.DataTable)

Dim da = New SqlDataAdapter(converteddata.ToString(), connectionString)
da.Fill(ds)
gvForms.DataSource = ds.Tables(0).DefaultView
gvForms.DataBind()


please provide me with the answers as soon as possible....
thank u
 
Back
Top