Single Cell Data

P

Paul W Smith

Please excuse the my frustration if it comes through while writing this
request for help.
I have created a DataGird and populated it with data from an
AccessDataSource. This was easy, I followed the steps from the various web
tutorials on ASP.NET within 15 minutes I have on a web page a display of the
content of my DB table, which I could alter by changing the SQL statement.

Now the next thing I wanted to do was display the contents of another DB
query, one that would return just one piece of information, and display that
on my web page as a page heading. Surely, I thought I do not have to
display this as another datagrid, it would be just one cell by one cell?

Well try as I might I cannot seen to find a simple way to display this
single piece of information, as neither the label, textbox or literal has
any way to bind data to it (well that I can find).

Can anyone please give me simple instructions on how to output the content
of a AccessDataSource to a single cell entitiy. Or confirm that everyone
else in the world uses a datagrid for this!



PWS
 
G

Guest

Please excuse the my frustration if it comes through while writing this
request for help.
I have created a DataGird and populated it with data from an
AccessDataSource. This was easy, I followed the steps from the various web
tutorials on ASP.NET within 15 minutes I have on a web page a display of the
content of my DB table, which I could alter by changing the SQL statement.

Now the next thing I wanted to do was display the contents of another DB
query, one that would return just one piece of information, and display that
on my web page as a page heading. Surely, I thought I do not have to
display this as another datagrid, it would be just one cell by one cell?

Well try as I might I cannot seen to find a simple way to display this
single piece of information, as neither the label, textbox or literal has
any way to bind data to it (well that I can find).

Can anyone please give me simple instructions on how to output the content
of a AccessDataSource to a single cell entitiy. Or confirm that everyone
else in the world uses a datagrid for this!

PWS

If you have a source like this

<asp:AccessDataSource id="AccessDataSource1" runat="server"
DataFile="....mdb" SelectCommand="Select Top 1 bla-bla...." />

you can get the value out of it referring to id of AccessDataSource
and a Select method.

For example, here I would get a first column of first row

<
%=((System.Data.DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty)).Table.Rows[0]
[0] %>

To make it more clear you can do the same having a piece of code as
here

<script runat="server">
private void Page_Load(Object sender, System.EventArgs e)
{
System.Data.DataView dv =
AccessDataSource1.Select(DataSourceSelectArguments.Empty);
string s = (string) dv.Table.Rows[0][0];
Label1.Text = s;
</script>

<asp:Label id="Label1" .....

Hope it works :)
 
P

Paul W Smith

Alexey,

Any chance of your advice in VB?

I am not sure how to implement your suggestion given it in in CS. I have
tried all alternatives but cannot get it to owrk :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top