Sign in to follow this  

[.net] gridview. putting data in a cell

Recommended Posts

Hi, i got a problem figuring out how to show data in a gridview without actually using a datasource. here's the deal: I'm using sessions to store the contents from a gridview from another page. I then want to extract that data in a list to fill certain cells in another gridview. like this.

list myData = (list)session["Data"];

For(int i = 0; i < myDate.Count; i++)
myDataGridView.Rows[i].Cells[0].text = myData[i].name; //string property
// ...

When i run the webapp, it won't give me an exception, but the page doesn't show my gridview, even though it is enablad and visible. Any help greatly appreciated. [Edited by - betabyte on March 14, 2010 8:46:28 AM]

Share this post

Link to post
Share on other sites

is data from list only data you want to put into grid? If so, you can just apply your list as datasource.
Also check grid property "AutoGenerateColumns".

At end, you need to bind data to grid. You can do this by calling "Bind" function:


I suggest you to read some advance articles toward GridView because this is one of most common used controls.

Share this post

Link to post
Share on other sites
Thanks for your reply.

I tried another aproach instead, like you pointed out.
I used an Objectdatasource and created a helper class to
make the listarray bindable.

thank you.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this