Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > GridView, accessing data

Reply
Thread Tools

GridView, accessing data

 
 
Doogie
Guest
Posts: n/a
 
      07-25-2007
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?

 
Reply With Quote
 
 
 
 
Phil H
Guest
Posts: n/a
 
      07-31-2007
On 25 Jul, 13:44, Doogie <(E-Mail Removed)> 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.

 
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
Accessing complex data from a linked list based data structure.. Ram C Programming 3 03-24-2009 02:15 AM
Need help in programmatically accessing the data returned by data access method... Siva ASP .Net 1 04-17-2006 06:48 PM
Accessing data in DataSet KavvY ASP .Net 2 07-14-2004 08:51 AM
RE: Accessing ADO.NET data provider from ASP "classic" page MSFT ASP .Net 0 08-12-2003 08:47 AM
Accessing data on a SQL-server =?iso-8859-1?Q?S=F8ren_Jensen?= ASP .Net 1 07-05-2003 01:42 PM



Advertisments