I have created a gridview in code behind (as in its not physically present on the page). I want to know how to call it’s rowdatabound event – as data is being bound to it. There happens to be a Gv.RowDataBound function, but how do I use it?
(I want the same functionality as what the asp:gridview control has for its onrowdatabind attribute…)
GridView Gv = new GridView();
Gv.AutoGenerateColumns = false;
BoundField one = new BoundField();
one.DataField = "one";
one.HeaderText = "One";
Gv.Columns.Add(one);
BoundField two = new BoundField();
one.DataField = "two";
one.HeaderText = "Two";
Gv.Columns.Add(two);
//dt is a datatable with some data
Gv.DataSource = (dt);
Gv.DataBind();
Set the eventhandler for the gridview using:
Then create its own eventhandler