I am trying to modify the datasource of a grid contained within a ASPxPageControl which is within a ASPxRoundPanel using the following code. An error is thrown (which follows the code) when the line "grdDiagnosis.DataSource = oDataSet" is executed. Any help would be appreciated.
Protected Sub grdDiagnosis_DataBinding(ByVal sender As Object, ByVal e As EventArgs) Handles grdDiagnosis.DataBinding
Dim cSqlSelect As String = "select * from xxx"
Dim oClasses As New UHCC_Classes
Dim oConnection As New SqlConnection(oClasses.GetConnectionString(Session("FilterCON_CONID")))
Dim oAdapter As New SqlDataAdapter(cSqlSelect, oConnection)
oAdapter.SelectCommand.CommandType = CommandType.Text
Dim oDataSet As New DataSet
grdDiagnosis.DataSource = oDataSet
Catch ex As Exception
pnlError.Visible = True
lblError.Text = "The 'grdDiagnosis' command failed. Error message returned follows:<br>" + ex.Message
And here is the error message I get...
The 'grdDiagnosis' command failed. Error message returned follows:
Data properties on data control 'grdDiagnosis' such as the DataSource, DataSourceID, and DataMember cannot be changed during the databinding phase of the control.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.