Method to Find GridView Column Index by Name

前端 未结 7 2107
萌比男神i
萌比男神i 2020-12-09 04:00

I\'m trying to write a small method to loop through and find a GridView Column by its Index, since it can change position based on what might be visible.

<
7条回答
  •  猫巷女王i
    2020-12-09 04:18

    In case if you need a column itself and not just its index you can use some Linq magic:

    DataControlField col=GridView1.Columns.Cast().First(c => c.HeaderText == "Column_header")
    

提交回复
热议问题