Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Single Cell Data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul W Smith - 04 Oct 2007 16:53 GMT
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 :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.