I am using c# asp.net and building a windows application. I have created a datagridview and set the datasource. Everything is working fine.
But I would like to add a new column in my DataGridView and set some value. These value is not available on the first level, but the second level of the item.
See below an example:
var searchResponse = await client.SearchAsync(searchParameters);
List<AuctionInfo> dataSource = searchResponse.AuctionInfo;
dataGridView1.DataSource = dataSource;
Now I would like to add the value "fullname" in a a new column:
foreach (var auctionInfo in searchResponse.AuctionInfo)
{
var item = await client.GetItemAsync(auctionInfo);
string fullname = string.Format("{0} {1}",item.FirstName,item.LastName);
}
How can I implement this?
There is an event called: "NewRowNeeded" if you set this you can put your value in the method.
An other opinion is to call the "dgv1.RowCount" Event to count the rows in the table... if you got this save the value on a variable. Just add +1 to the counter:
CODE
int counter = dvg1.RowCount ;
counter ++;
dvg1.Rows[counter].Cells[0].Value = "do some stuff here";
you can call and set each cell with editing the Cells[].
I hope this will help you! If it won´t pls set a comment and I will try to write some Code for you. Have a nice day!