473,382 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

DataBinding Through Code

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_PatientSelectTableAdapte r"
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

Jan 11 '07 #1
2 1025
the actual databind.

gvPatientResults.DataBind();

-- bruce (sqlwork.com)

Mike wrote:
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_PatientSelectTableAdapte r"
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
Jan 11 '07 #2
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

Jan 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
8
by: Tim_Mac | last post by:
hi, i have a group of individual radio buttons that i am running some client-side code on for the onClick event. there is a URL generated by a code block inside the onClick attribute. the...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
4
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the...
1
by: Heather Crow | last post by:
I have a VS.NET 2003 Visual Basic form which keeps hanging. It does not appear to matter what textbox I am on. When trying to edit the field I cannot move focus from this field to another. Clicking...
3
by: Dan Slaby | last post by:
I have a webservice that I want to populate a combobox on a windows form. The webservice creates the correct XML output, but when I attempt to bind it to a combobox I get this error: Additional...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
1
by: avf | last post by:
hi all. in my code i bind a few dropdownlist boxes's lists, datasource etc. i bind the Selectedvalue property, and everything is fine. then one bright day, WITHOUT ANY CHANGE TO THE DATABINDING...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.