
 Rank: Guest Groups: Guest
Joined: 9/17/2007 Posts: 11,670 Points: -1,200
|
Date parsed: 04/10/2007 18:27:11 Date: Thu, 04 Oct 2007 18:27:11 -0000
On Oct 4, 5:53 pm, "Paul W Smith" <p...@NOSPAM.twelve.me.uk> wrote: > 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 :-)
|

 Rank: Guest Groups: Guest
Joined: 9/17/2007 Posts: 11,670 Points: -1,200
|
Date parsed: 04/10/2007 19:53:52 Date: Thu, 4 Oct 2007 17:53:52 +0200
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
|

 Rank: Guest Groups: Guest
Joined: 9/17/2007 Posts: 11,670 Points: -1,200
|
Date parsed: 05/10/2007 21:52:41 Date: Fri, 5 Oct 2007 19:52:41 +0200
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] %> > > 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 :-) >
|