DataBinding Through Code

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi all

I'm trying to do something that seem rather simple in theory but just
doesn't want to work out.

I have a form with a text box used to type in a search criteria, a drop
down list used to select what field to search and a button to execute
the search. All the samples I can find are binding when the form loads
which I don't want to do since there are several thousand records.

I have a GridView that's supposed to display the results. When the
button is clicked I create an ObjectDataSource 0and connect that to a
middle layer business object.

Dim odsPatients as ObjectDataSource = New ObjectDataSource
odsPatients.TypeName =
"dsSearchTableAdapters.sp_PatientSelectTableAdapter"
odsPatients.SelectMethod = "SearchPatients"

Then I add and set the values of the select parameters based on what
field to search and the criteria.

Next I bind the GridView to the ObjectDataSource

gvPatientResults.DataSourceID = odsPatients.ID
gvPatientResults.DataMember = "PID"

Is there something I'm missing?

THanks
 
Thanks for the reply.

I added the databind but it's still not working. I think the problem
has to do with setting the datasourceID. As I'm stepping through the
code, the statement gvPatientResults.DataSourceID = odsPatients.ID is
where I think the problem lies. When I hold the cursor over the
odsPatients.ID the value is nothing.

Any thoughts??
THanks
 
Back
Top