Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ObjectDataSource's underlying data/schema

Reply
Thread Tools

ObjectDataSource's underlying data/schema

 
 
=?Utf-8?B?RGljaw==?=
Guest
Posts: n/a
 
      03-01-2006
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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      03-01-2006
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.

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-01-2006
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.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesn't VS.Net select the Underlying HTML code? vijaynats@yahoo.com ASP .Net 1 02-28-2005 04:47 PM
COM object that has been separated from its underlying RCW can not be used. Rahul T. ASP .Net 3 12-03-2004 12:24 AM
ACS SE underlying OS? Frank Fegert Cisco 0 07-25-2004 08:59 PM
PIX to Checkpoint IPSEC connection with identical underlying subnets Saucy Levine Cisco 1 12-08-2003 10:04 PM
Underlying connection was closed sumit ASP .Net 0 11-01-2003 11:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57