Link to home
Start Free TrialLog in
Avatar of pratikshahse
pratikshahse

asked on

Populate a DataGrid or Gridview

I want to populate a datagrid and the data is not going ot come from any database. what i have is an object and i am going through loop through different values in that object and then populate the datagrid with the values that I get after  each loop.

this is what i want to do:

loop through object:
{
string x = object.somevalue
string y = object.somevalue

populatedgrid(x,y)
}


Function populategrid (sting x, string y)

populate grid by appending new values.





Avatar of Astynax777
Astynax777
Flag of United States of America image

Are the number of columns predefined?
ASKER CERTIFIED SOLUTION
Avatar of Astynax777
Astynax777
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tvPrasad
tvPrasad

myGridView.DataSource = <your object name goes here>;
   myGridView.DataBind();
It needs to be done like, Create a datatable, Add object values into the datatable, just bind the datatable.

thats it