0
votes

How can I set the OnRowDataBound method name from code behind?

Aspx code:

OnRowDataBound = "gvResults_RowDataBound"

How to set that from code behind?

gvResults.Attributes["OnRowDataBound"] = "gvResults_RowDataBound";

does not work.

1

1 Answers

5
votes

You have to use the RowDataBound event handler from the GridView:

gvResults.RowDataBound += gvResults_RowDataBound;