I have a generic List which is populated with an object which has properties like FirstName, Surname etc.
If I bind a gridview to the list with autocompletecolumns = true, the Gridview displays the data in the List.
The code looks like:
DataAccess da = new DataAccess();
gvUserList.DataSource = da.getUsers(2);
gvUserList.DataBind();
If I were using a SqlDataReader to populate the GridView I would be able to do something like this:
gvUserList.DataSource = myDataReader;
gvUserList.DataKeyNames = new string[] { "FirstName", "Surname" };
gvUserList.DataBind();
My question is:
How do I populate the DataKeyNames with the properties (FirstName, Surname) contained in the object that is contained in each element of the Generic List?
Thanks for any help.
...
Go to the complete details ...