473,396 Members | 2,023 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,396 software developers and data experts.

ObjectDataSource - How do I get at the returned data? (Not using a gridview)

Ian
Hiya,

Hope this isn't too stupid a question :)

I can bind an objectdatasource to a gridview very easily (and there's a
thousand tutorials of this on the net).

BUT!

I just want to get at the data so I can say put it in a label.text, or
similar. I've set an objectdatasource up that gets one record from my table,
representing a customer, and I just want to for example to display the
customer name somewhere on the page (other than via a gridview). I think I
was hoping for some sort of MyObjectDataSource.Table property so that I
could start getting at the returned values.

Please help! I'm sure it's ridiculously easy but it's not obvious to little
old me who until now thought .net 2 was looking oh so shiny.

Thanks a lot!

Ian

Mar 3 '06 #1
2 3776
The Selected event can be used for this:

protected void ActionsDataSource_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
dt = (ObjDataSet.ActionseDataTable) e.ReturnValue;

foreach (xx in dt)
{
}
}

But this result doesn't have the FilterExpression applied (it's the
datatable, not the dataview). dt.DefaultView doesn't work either, so if
anyone knows how to access the filtered results let me know!

I think you can also manually bind the objectdatasource, that way calling
your business object yourself, and manipulating the resultant dataset before
binding.

John

"Ian" <pl*********@Iwantnospam.com> wrote in message
news:t5********************@eclipse.net.uk...
Hiya,

Hope this isn't too stupid a question :)

I can bind an objectdatasource to a gridview very easily (and there's a
thousand tutorials of this on the net).

BUT!

I just want to get at the data so I can say put it in a label.text, or
similar. I've set an objectdatasource up that gets one record from my
table, representing a customer, and I just want to for example to display
the customer name somewhere on the page (other than via a gridview). I
think I was hoping for some sort of MyObjectDataSource.Table property so
that I could start getting at the returned values.

Please help! I'm sure it's ridiculously easy but it's not obvious to
little old me who until now thought .net 2 was looking oh so shiny.

Thanks a lot!

Ian


Mar 3 '06 #2
In general, the new data source controls (object, sql & xml) are designed to
work with the new data presentation controls (gridview, detailsview,
formsview). There is no way to directly bind a "naked" label control to a
ODS but you can wrap it within a formsView:

<asp:FormView ID="FormView1" runat="server"
DataSourceID="ObjectDataSourceMain" AllowPaging="True">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("LocationCode")
%>' />
</ItemTemplate>
</asp:FormView>

You may or may not need paging depending on the number of records returned
by your data object.

Hope this helps,

--

Andrew Robinson
http://blog.binaryocean.com
"Ian" <pl*********@Iwantnospam.com> wrote in message
news:t5********************@eclipse.net.uk...
Hiya,

Hope this isn't too stupid a question :)

I can bind an objectdatasource to a gridview very easily (and there's a
thousand tutorials of this on the net).

BUT!

I just want to get at the data so I can say put it in a label.text, or
similar. I've set an objectdatasource up that gets one record from my
table, representing a customer, and I just want to for example to display
the customer name somewhere on the page (other than via a gridview). I
think I was hoping for some sort of MyObjectDataSource.Table property so
that I could start getting at the returned values.

Please help! I'm sure it's ridiculously easy but it's not obvious to
little old me who until now thought .net 2 was looking oh so shiny.

Thanks a lot!

Ian


Mar 3 '06 #3

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

Similar topics

1
by: Dotnet Gruven | last post by:
I've posted this in the adonet group, however it was suggested I might have better luck here.... ============================================================= I'm trying to use a typed dataset and...
5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
3
by: mthomason | last post by:
I keep getting this error when trying to update records using an ObjectDataSource. I have seen others post similar errors...but I haven't found any solutions. ObjectDataSource...
9
by: J055 | last post by:
Hi I'm trying to get an instance of UserLists to persist after it's been used by the GridView. I understand from the documentation that The OnObjectCreated event allows access to the instance. I...
0
by: avital | last post by:
Hi, Hope someone can please help. I have a Gridview with a checkboxlist. On edititemTemplate I want the checkboxlist items to be selected as returned from the database. In the database I...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
0
by: Phillip Ian | last post by:
Tried this over in CSharp.General and didn't get anything, so I thought I'd try again here. If there's an AJAX specific group I could ask this in, please let me know...I did look. I'm trying to...
5
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.