GridView, accessing data

D

Doogie

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?
 
P

Phil H

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.
 

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,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top