I am using .net 4.5 and I found this odd behaviour:
Markup:
<asp:DetailsView ID="dtvTest" AutoGenerateRows="true" DefaultMode="Insert" runat="server" />
Code:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable("Test");
dt.Columns.Add("Column", typeof(string));
// If I uncomment the line it works!
// dt.Rows.Add("row 1");
dtvTest.DataSource = dt;
dtvTest.DataBind();
}
the result is
Collection cannot be null. Parameter name: c
thrown on dtvTest.DataBind().
If there is at least one row it works!! (see the commented line).
Any idea on how to fix/work around it?
Many thanks