c# - Access column name in a loop using GridViewRowEventArgs -
I have GridView
, which adds hyperlinks to all the values in the based on the data Is DataTable
. This is being achieved using the "GridViewRowEventArgs" functionality but here I have to use the column names in the loop and I am unable to do this. Please help me with this.
You can use this extension:
public stable C GetColumnIndex (this gridview grid, string columnname) {return grid. Columns Cast & Lieutenant; Data Control Fields & gt; (). Select ((c, index) = & gt; new {column = c, index = index}). X = & gt; X.Column.HeaderText.Equals (column name, string commerment. Invent culture Ignore case). Select (x = & gt; x.Index). Default effect (-1). first (); }
Then you can use it like this:
Secure Zero GridView_RadataBound (Object Sender, GridViewEventErgus E) {If (E.O. Row Type = = DataControlRowType.DataRow) {GridView Grid = (GridView) Sender; Int Index of Column = Grid GetColumnIndex ("ColumnName"); // E. For example Ro Seals e Ro To reach the correct indicator in Seals [indexofkualam]. Text = "hello"; }}
Comments
Post a Comment