?
Solved

Data Binding

Posted on 2011-03-10
4
Medium Priority
?
214 Views
Last Modified: 2012-05-11
I am still learning C# and would like to know what the most efficient means is to bind data from a database into this simple application I have written. I'm still very confused by DataGrids, Data tables, Data Sets, Adapters, etc. I think there's something basic I am not getting.

The application is as follows:

The user enters some parameters X, Y, Z about themselves, and then the application goes to the datbase and finds X, Y, Z (all keys in the table) and returns A, B.  There is only ONE resulting row containing A and B, never more than one row. I need to display A and B on the page in a Label field, so how do I get this result and display it?

What should I use? Seems like overkill to use a Data grid or data table for just one resulting record.

Once I get the result set back, can I bind it to a label field? or does it have to be bound to a repeater (also overkill for this application).

I got as far as the DataAdapter, but I'm not sure what to do from there. Help!
0
Comment
Question by:vcbertini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1000 total points
ID: 35100063
You basically have a few groups of object that go together. A DataSet is a container object that holds one or more DataTables. A DataAdapter acts as an intermediary between between the DataSet and your database. DataReaders are fast, light-weight data objects that give you forward-only access to your data (this would be the most suitable in your scenario).

The DataGrid, Repeater, etc, are UI elements that display data stored in DataTables/DataSet or pulled back with a DataReader.

Labels are dumb, in the sense that the do not directly support databinding in their own right. They can pull data from a data source, but only when they are inside a data-aware control such as a grid or repeater, etc.  
0
 

Author Comment

by:vcbertini
ID: 35100083
So I would probably have to use a repeater even though there's nothing that will repeat?

...and I would bind the repeater to the data reader?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35100101
Not necessarily. A DetailsView might suit your purpose because it is designed for displaying a single record at a time:

    http://msdn.microsoft.com/en-us/library/s3w1w7t4.aspx
0
 

Author Closing Comment

by:vcbertini
ID: 35100122
Hmm... Food for thought. Thank you very much!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question