Solved

Data Binding

Posted on 2011-03-10
4
212 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 250 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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