Hello,
Would anyone be able to help me as im kind of stuck. My plans are too populate a data grid with data from an object. The object will be populated from a Query, which I dont no as it will be dynamic - thats why im not just creating a connection, and using the data source!
So iv managed too pull data from my database, but now Im having trouble wondering how I can get data from my database into the data grid!
Any help would be appriated!
adam
You should be able to loop and retrieve the data using something such as:
while(theObject.Read())
{
Response.Write(theObject["ColumnName"]);
}
What you'll want to do inside the while loop is to create a new DataGrid row, set the values for the cells and add it to your DataGrid. Here are more details: http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21507588.html
However, if you don't plan to use the DataGrid specific features, you're better of using a Table object (typical HTML table) and create new rows. It should be easier.
I decided in the end to use a library i made called Dynamic Object, it allows me too generate members for objects dynamically and then later pull them out of the object using a foreach loop without ever knowing the member names. Only problem is the object doesnt actually exist, so it would be impossible to apply methods too the objects, enless the contrainer object extended from a code based object ...
Thanks for the help!