Filling Property data into DataGridView
hi friends , i have been trying to fill datagridView .but i am getting the folloiwng error .
Error 2 The best overloaded method match for 'System.Windows.Forms.DataGridViewColumnCollection.Add(System.Windows.Forms.DataGridViewColumn)' has some invalid arguments C:\TradingSummary\TradingSummaryStatus\FrmBrands.cs 73 17 TradingSummaryStatus
Error 3 Argument '1': cannot convert from 'string' to 'System.Windows.Forms.DataGridViewColumn' C:\TradingSummary\TradingSummaryStatus\FrmBrands.cs 73 43 TradingSummaryStatus
Code:
public void FillBrandMaster(){
foreach (Brand _brand in _brands)
dataGridView1.Columns.Add(_brand.BrandID).ToString();
}
Re: Filling Property data into DataGridView
In your original code, You have the .Tostring in the wrong place. The way you have it, you are trying to ".ToString" the .ADD method of the columns collection of the datagridview. I assume you what to "ToString" the brandID. So change the code to...
Code:
public void FillBrandMaster(){
foreach (Brand _brand in _brands)
dataGridView1.Columns.Add(_brand.BrandID.ToString());
}