How to access a gridview column on rowdatabound ?

前端 未结 3 1390
渐次进展
渐次进展 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条回答
  •  猫巷女王i
    2021-02-06 12:59

    Cleaner easier to read LINQ. Tim's did not work for me.

    private int GetFirstGridViewColIndex(string dataField, object sender)
    {
        var boundFieldColumns = ((GridView)sender).Columns.Cast();
    
        return boundFieldColumns.Where((column, index) => string.Equals(column.DataField, dataField, StringComparison.InvariantCultureIgnoreCase))
            .Select((column, index) => index)
            .First();
    }
    

提交回复
热议问题