ObjectDataSource's underlying data/schema

G

Guest

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.
 
S

Steven Cheng[MSFT]

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top