views:

426

answers:

4

when I write this query (using LINQ):

        Dim hw22 = From hw In db.HWs _
                   Select hw

then:

        GridView2.DataSource = hw22
        GridView2.DataBind()

this error occurs: http://www.rofof.com/img2/6hscmu7.gif

How can I solve this?

A: 

you probably have the DataSourceId defined in markup code

Thomas Levesque
how can I solve it ?
turki2009
remove the DataSourceId definition from the .aspx file
Thomas Levesque
how can I rem you hove it ? can you help me please ?
turki2009
A: 

remove DataourceID from html source of gridViewdio

Open aspx page in visual studio

click on source , this will show you html source of the page

look for this line of code

inside this tag there will be a line like DataSourceID = something ,,,,,remove this

A: 

Is it possible to define the datasource ID in the gridview and dynamically bind it to another datasource during one condition????

Kreshiv
Yes, you can change the datasourceid or datasource as much as you want as long as when there is a call to databing only one is defined.
jarrett
+1  A: 

If you don't want to remove it in markup then do this:

GridView2.DataSourceID = ""
GridView2.DataSource = hw22
GridView2.DataBind()
jarrett