• Advertisement
Sign in to follow this  

[.net] gridview. putting data in a cell

This topic is 2900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.Cells[0].text = myData.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
Advertisement
Hi,

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:

myDataGridView.Bind();

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
Sign in to follow this  

  • Advertisement