ObjectDataSource's underlying data/schema

Discussion in 'ASP .Net' started by =?Utf-8?B?RGljaw==?=, Mar 1, 2006.

  1. 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.
     
    =?Utf-8?B?RGljaw==?=, Mar 1, 2006
    #1
    1. Advertising

  2. You can use the DataItem property of the GridViewRow as you handle the
    GridView.RowDataBound event:
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrow.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.
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 1, 2006
    #2
    1. Advertising

  3. 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.)
     
    Steven Cheng[MSFT], Mar 1, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,677
    Markus
    Nov 23, 2005
  2. Joyce
    Replies:
    0
    Views:
    588
    Joyce
    Mar 1, 2005
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,334
    Stanimir Stamenkov
    Apr 25, 2005
  4. Replies:
    0
    Views:
    679
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    269
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page