I am trying to insert column into gridview, I have dropdown below the grid and dropdown is having 10 items now If i select random item assume that I am selecting 8 number item and add clicking add button. this item should create as new column at 8 number in grid.
Suppose grid is not having any column when page is loading and trying to insert column using below code throwing error.
var boundField = new TemplateField { HeaderText = "SelectedProductName"}; grd.Columns.Insert(ddlProduct.SelectedIndex, boundField);
As Selected index can be any random number but grd is throwing out of index error as grid does not have that position.
Could you please help me to insert new column based on selected index from the dropdown.
My goal to achieve to display grid columns as they are listing into the dropdown same sequence.