|
Need both form level and Code Behind Gridview VB.NET
Hey, guys question for you. I am getting an error, both datasource and datasourceID defined, please remove one of them. what I am trying to do is to set default values for a gridview from the pageload event and also allow the form level usage of datasourceID to set data inside the gridview. I am trying to set the data inside the pageload event, how do I do these without triggering this error? I have tried to remove the DatasourceID reference but then I cannot set it back without causing another error or else not getting it back to form level. Any ideas?
'Open up the connection
SQLConnection.Open()
'HERE WE NEED TO SET INITIAL GRIDVIEW VALUES
Gridview1.DataSource = Nothing
Gridview1.DataSourceID = Nothing
Gridview1.DataBind()
Dim dsGridViewData As DataSet = New DataSet
Dim daGridview As SqlDataAdapter = New SqlDataAdapter()
'GET ACTUAL BASE PERSON FROM SELECTED INDEX IN GRIDVIEW
Dim sqlStrGridView As String = "SELECT *" & _
"FROM TblDotNetAncestorsTree where uniqueID = '" & "12334546456" & "'"
daGridview = New SqlDataAdapter(sqlStrGridView, SQLConnection)
daGridview.Fill(dsGridViewData)
Gridview1.DataSource = dsGridViewData
Gridview1.DataSource = Nothing
Gridview1.DataSourceID = "SqlDataSourceGridView"
Here I would like to set it back so that it is usable at the form level, but its not working, any ideas?
|