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
Alexey Smirnov - 04 Oct 2007 19:27 GMT
> Please excuse the my frustration if it comes through while writing this
> request for help.
[quoted text clipped - 17 lines]
>
> 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 :-)
Paul W Smith - 05 Oct 2007 18:52 GMT
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 :-(
> %=((System.Data.DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty)).Table.Rows[0]
> [0] %>
[quoted text clipped - 14 lines]
>
> Hope it works :-)