How to access a gridview column on rowdatabound ?

前端 未结 3 1385
渐次进展
渐次进展 2021-02-06 12:09

I would like to change the value of my gridview column to active when the value is 1. I have gridview column like



        
3条回答
  •  执笔经年
    2021-02-06 13:01

    You could loop all columns to get the correct index or use this LINQ:

    String colToFind = "status";
    int colIndex = ((GridView)sender).Columns.Cast()
                    .Where((c, index) => c.HeaderText.ToLower().Equals(colToFind))
                    .Select((c,index)=>index).First();
    

提交回复
热议问题