473,382 Members | 1,705 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,382 software developers and data experts.

ObjectDataSource's underlying data/schema

How do I get to an ObjectDataSource's underlying data/schema. I thought it
would have a DataSet property but I can't find it. So how do you find out
about the data and/or the schema used to populate a bound control such as the
GridView?

Specifically I want to do something like this...

For Each BoundControl in GridView1
If the DataType of the BoundControl is DateTime Then
BoundControl.HtmlEncode="false"
BoundControl.DataFormatString="{0:d}"
End If
Next BoundControl

I thought I would find a property on the BoundControl that would lead me to
a DataRow object. Or otherwise perhaps I could use the BoundControl's ordinal
to find the corresponding DataColumn from the DataSet's DataTable object. But
I can't see how to do any of these things.
Mar 1 '06 #1
2 1812
You can use the DataItem property of the GridViewRow as you handle the
GridView.RowDataBound event:
http://msdn2.microsoft.com/en-us/lib....dataitem.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dick" wrote:
How do I get to an ObjectDataSource's underlying data/schema. I thought it
would have a DataSet property but I can't find it. So how do you find out
about the data and/or the schema used to populate a bound control such as the
GridView?

Specifically I want to do something like this...

For Each BoundControl in GridView1
If the DataType of the BoundControl is DateTime Then
BoundControl.HtmlEncode="false"
BoundControl.DataFormatString="{0:d}"
End If
Next BoundControl

I thought I would find a property on the BoundControl that would lead me to
a DataRow object. Or otherwise perhaps I could use the BoundControl's ordinal
to find the corresponding DataColumn from the DataSet's DataTable object. But
I can't see how to do any of these things.

Mar 1 '06 #2
Thanks for Phillip's informative input.

Hi Dick,

As Phillip has mentioned, generally if we want to do some custom tasks to
format the data which will be bound to the Databound controls, we can use
those template databound's (Item)DataBound event. e.g the GridView has the
"RowDataBound" event. There we can get the reference to the bound
datasource's dataitem and query data from it...

Also, as for ObjectDataSource control, it can be used to associate
different kind of data access component classes, not only limited to
TableAdapter/Dataset. So the customization about the databound control or
user interface is not related to the objectDataSource.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 1 '06 #3

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

Similar topics

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...
2
by: J055 | last post by:
Hi I've implemented caching for my ObjectDataSource. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnableCaching="True" CacheDuration="10" CacheExpirationPolicy="Sliding" ...
2
by: SJL | last post by:
I have a GridView (ASP.NET 2.0 + SQL Sever 2005) control that is bound to an Object Data Source (ODS). The ODS has a SelectParameter for the sort expression. The SelectParameter has a DefaultValue...
0
by: Richard Carpenter | last post by:
I am working on a small project in which I am trying to implement a data access layer through the use of a project dataset schema. Data integrity and normalization will be handled through the use...
10
by: J055 | last post by:
Hi I've been trying out SqlCacheDependency using the ObjectDataSource and SQL Server 2005. It all works quite well with the minimum of configuration, e.g. <asp:ObjectDataSource...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
6
by: =?Utf-8?B?V2F5RG93blVuZGVy?= | last post by:
When I link an ObjectDataSource to a business object, it appears that the Refresh Schema button does nothing. I have added a property to the business object and want to display this new property...
0
by: yisroem | last post by:
Hi Everybody, I am just getting to grips with ASP.NET 2.0. as per my reading I understand that it is possible for a data control (such as the GridView, DetailsView etc.) to reflect upon the...
1
by: Axel Dahmen | last post by:
Hi, I'd like to retrieve and step through an ObjectDataSource's columns to be able to manually add BoundFields to a GridView control. I don't know how to do this other than to manually call...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.