GridView, accessing data

Discussion in 'ASP .Net Web Controls' started by Doogie, Jul 25, 2007.

  1. Doogie

    Doogie Guest

    Hi
    I have a gridview on my web page and I bind it to an object of my own
    creation. When I click a button on that page, I want to get the data
    from that gridview and cast it back into that object I created and
    start to do work on it. I tried something like this:

    List<MyObject> myObject = (List<MyObject>)myGrid.DataSource;

    But I noticed that when I get to this line, "myGrid.DataSource" is
    null. Yet, I can access the "myGrid.Rows.Count" value and see the
    correct number of rows in my grid.

    How can I convert to my own object?
    Doogie, Jul 25, 2007
    #1
    1. Advertising

  2. Doogie

    Phil H Guest

    On 25 Jul, 13:44, Doogie <> wrote:
    > Hi
    > I have a gridview on my web page and I bind it to an object of my own
    > creation. When I click a button on that page, I want to get the data
    > from that gridview and cast it back into that object I created and
    > start to do work on it. I tried something like this:
    >
    > List<MyObject> myObject = (List<MyObject>)myGrid.DataSource;
    >
    > But I noticed that when I get to this line, "myGrid.DataSource" is
    > null. Yet, I can access the "myGrid.Rows.Count" value and see the
    > correct number of rows in my grid.
    >
    > How can I convert to my own object?


    Hi Doogie

    Are you sure that the Gridview is bound by the DataSource property and
    not DatasourceID? They are not the same. The former requires an
    explicit execution of the Databind method to load the data the latter
    does not.
    Phil H, Jul 31, 2007
    #2
    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. Replies:
    3
    Views:
    5,096
  2. Siva
    Replies:
    1
    Views:
    448
    =?Utf-8?B?UmljaA==?=
    Apr 17, 2006
  3. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,944
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  4. Rasika WIJAYARATNE
    Replies:
    0
    Views:
    600
    Rasika WIJAYARATNE
    Dec 14, 2007
  5. Sergio E.

    get data that fills gridview inside the gridview

    Sergio E., Aug 8, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    212
    Sergio E.
    Aug 8, 2007
Loading...

Share This Page