views:

356

answers:

1

Does anyone have an example of a formview with a gridview inside the EditTemplate using c#? The datasource of the gridview is a datatable.

When setting the dt datasource I get the error Object reference not set to an instance of an object

Gridview gv1 = (Gridview)fv1.FindControl("gv1") as GridView;
DataTable dtH = gv1.DataSource as DataTable
dtH = hist.Fetch(acct,dt);

Thanks

A: 

Try this:

Gridview gv1 = fv1.FindControl("gv1") as GridView;
if (gv1 != null)
{
  DataTable dtH = gv1.DataSource as DataTable
  dtH = hist.Fetch(acct,dt)
}
David Glass