I created a gridview and I used the SqlDataSource wizard because I wanted to leverage all of the paging sorting editing etc, that it makes real easy. The problem is that once the initial data is displayed I need to be able to search.
So I create codebehind connection
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sql3 As String
Dim strConn3 As String
Dim ds3 As DataSet = New DataSet
strConn3 = ConfigurationManager.ConnectionStrings("EMS_MainConnectionString").ConnectionString
Dim Conn3 As New SqlConnection(strConn3)
sql3 = "SELECT * FROM [tblAED_Address_Contact_Info] where organizationname like '%" & txtOrgName.Text & "%'"
Dim cmd3 As New SqlDataAdapter(sql3, Conn3)
cmd3.SelectCommand.CommandTimeout = 200
GridView1.DataSourceID = ""
GridView1.DataSource = ds3
This works and avoids the "Both DataSource and DataSourceID are defined on 'GridView1'". error, but I lose all functionality gained by using the SqlDataSource in the first place. I am looking to have my cake and eat it too i guess.