c# - hide columns by Id in gridview in asp.net -


I have an asp.net application, where I am creating editable grid view with editing, delete, add options, normal Template field in the form of this grid as I want to hide some columns. I know that I can do this by using the column index. But I do not want to follow it. Instead, I want to hide the columns based on ID. This is because if I need to add more columns to my application, then need to get the code and then change it to the original. So I'm choosing this way. As i & lt; Asp: TemplateField / & gt; has not included the ID attribute, so for me, & lt; Asp: TemplateField / & gt; It becomes impossible to hide. Is there any solution for this?

You can always use column header text. Run a loop through the column of grid view and compare the column header header with continuous declaration and hide the column, in this way, if you add columns before or after the columns, the code will not affect.

Comments