We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding Columns

Hi, I am using DataboundGrid. I added 10 columns using m_ListingTable.Columns.Add(new DataColumn("1")); I want to access same columns using GridBoundColumns How do i do that. It threw exception when i used the below code for (int start = 0; start < m_ListingTable.Columns.Count; start++) { GridBoundColumn column = new GridBoundColumn(); column.MappingName = m_ListingTable.Columns[0].ColumnName.ToString(); column.HeaderText = m_ListingTable.Columns[0].ColumnName.ToString(); if (!m_ListingGrid.GridBoundColumns.Contains(column)) { m_ListingGrid.GridBoundColumns.Add(column); } }

1 Reply

AD Administrator Syncfusion Team April 21, 2005 07:32 AM

Each of the DataColumns needs a different name, so you cannot create all ten using the name "1". In your loop, try using start instead of 0. column.MappingName = m_ListingTable.Columns[start].ColumnName.ToString(); column.HeaderText = m_ListingTable.Columns[start].ColumnName.ToString();

Loader.
Live Chat Icon For mobile
Up arrow icon