473,322 Members | 1,352 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,322 software developers and data experts.

Simple databind for Label?

It was very easy to display the data of an 'AccessDataSource' using
GridView. But is it possible to display it with Label? I found that
there's no DataSourceID attribute for Label, so I think it might be
like,

label.Text=accessDataSource.Select(...);

Am I right? But I don't know how to use this Select(). I looked up MSDN
library but there was no example. The sql query string I set for the
accessDataSource should return a scalar value, but Select() returns
IEnumerable. How can I get the interger value from the IEnumerable?
Please show me simple example for this job. Thanks.

Feb 6 '06 #1
1 1322
I don't know exactly, but here is a hint:
The Select method returns a DataView object, if the DataSourceMode property
is set to the DataSet value, or a IDataReader object, if the DataSourceMode
property is set to the DataReader value. Close the IDataReader object when
you have finished reading the data.
Cast your return object, as one of the Concrete objects.

string x = (DataView) accessDataSource.Select(...) [0] [1];

(this probably won't work, but I'll explain)

cast the Select as a DataView
[0] means the first Row of data.
[1] means the second column of data. (Select a,b from table1)([1] would be
"b")

You'll have to experiment.

The reason its a IEnumerator is because Select could bring back 3 different
objects.
DataView, or DataSet, and IDataReader. All 3 of those probbably implment
IEnumerator.

DataView might be the wrong cast, fyi. I didn't test the code, I am just
giving a suggestion.


<ty*******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
It was very easy to display the data of an 'AccessDataSource' using
GridView. But is it possible to display it with Label? I found that
there's no DataSourceID attribute for Label, so I think it might be
like,

label.Text=accessDataSource.Select(...);

Am I right? But I don't know how to use this Select(). I looked up MSDN
library but there was no example. The sql query string I set for the
accessDataSource should return a scalar value, but Select() returns
IEnumerable. How can I get the interger value from the IEnumerable?
Please show me simple example for this job. Thanks.

Feb 6 '06 #2

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

Similar topics

5
by: Mike | last post by:
For ASP .Net display of a protected value what's better <%# %> (with DataBinding) or the ASP <%= %>? Is one more efficent or is there no difference? Thank you.
3
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
2
by: hellrazor | last post by:
Hi there, I'm successfully streaming a list of items into a radiobuttonlist. I am using an ArrayList as a data source, which I have built from a table of values in a MySQL table. It's working...
1
by: Martin | last post by:
Hi, I've got a web label control which I set a databind expression on the Text attribute in the html for the page (aspx file). At runtime, I want to override this attribute, so before I do...
2
by: Roy | last post by:
This may seem silly, but I'm just curious... I've noticed that in the code-behind, asp:Label has the .DataBind property yet has NO corresponding .DataSource property? Am I missing something? How...
2
by: Eniac | last post by:
*argh* ... *pull hairs* I've recently started developing from ASP to ASP.NET The switch was fairly smooth since i had done some VB.net before ... then came...FORMS! :) I find it astounding...
2
by: craigkenisston | last post by:
In Asp.Net 2.0 I need to create a very special layout with data coming from an ObjectDataSource. It was already working using a GridView, but I need a free layout. So, I dropped the GridView and...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
2
by: Steve Hershoff | last post by:
Hi everybody, I have a question about asp.net's labels and the DataBind method. I have a method in a code-behind page (this is VisualStudio 2003 btw) that (simplified) looks like this: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.