W
Webfriebd13
Guest
HI All,
I know this question is been asked multiple times in this forum but I am still facing the problem.
I have looked at the following link.
http://social.msdn.microsoft.com/fo.../thread/bd291e0c-dee8-45c1-bee1-54509fdf3c4f/
http://www.timvw.be/adding-datagridviewcolumns-lots-of-them/
But I am not able to find the solution to the problem. I am using VS2010 and I am trying to bind 900 columns.
The code looks like this:
DataGridViewColumn[] columns = new DataGridViewColumn[ds.Tables[0].Columns.Count];
dgTab.AutoGenerateColumns =
false;
for (int i = 0; i < columns.Length; ++i)
{
DataGridViewColumn column = new DataGridViewTextBoxColumn();
column.FillWeight = 1;
columns = column;
}
this.dgTab.Columns.AddRange(columns);
dgTab.DataSource =
null;
dgTab.DataSource = ds.Tables[0];
=================================================================================================================
If I set column.FillWeight = 0, I get run time error saying FillWeight cannot be 0. That why I have set it to 1.
Also, I have a row enter event where I am trying to get the parentId
int participantID = Convert.ToInt32(dgTab.Rows[e.RowIndex].Cells["ParentID"].Value);
I get error saying:
Column named ParentID cannot be found.
Parameter name: columnName
I think the data is not getting binded to the grid properly. Please share the code which will resolve the problem.
Continue reading...
I know this question is been asked multiple times in this forum but I am still facing the problem.
I have looked at the following link.
http://social.msdn.microsoft.com/fo.../thread/bd291e0c-dee8-45c1-bee1-54509fdf3c4f/
http://www.timvw.be/adding-datagridviewcolumns-lots-of-them/
But I am not able to find the solution to the problem. I am using VS2010 and I am trying to bind 900 columns.
The code looks like this:
DataGridViewColumn[] columns = new DataGridViewColumn[ds.Tables[0].Columns.Count];
dgTab.AutoGenerateColumns =
false;
for (int i = 0; i < columns.Length; ++i)
{
DataGridViewColumn column = new DataGridViewTextBoxColumn();
column.FillWeight = 1;
columns = column;
}
this.dgTab.Columns.AddRange(columns);
dgTab.DataSource =
null;
dgTab.DataSource = ds.Tables[0];
=================================================================================================================
If I set column.FillWeight = 0, I get run time error saying FillWeight cannot be 0. That why I have set it to 1.
Also, I have a row enter event where I am trying to get the parentId
int participantID = Convert.ToInt32(dgTab.Rows[e.RowIndex].Cells["ParentID"].Value);
I get error saying:
Column named ParentID cannot be found.
Parameter name: columnName
I think the data is not getting binded to the grid properly. Please share the code which will resolve the problem.
Continue reading...