Using DetailsView to insert when the DataSet is Empty

Programming Add comments

Scott Mitchell has what is probably the smoothest solution for the GridView which works for the DetailsView just the same:

  1. Put a DetailsView into the EmptyDataTemplate of the “parent DetailsView”
  2. Bind it to the same datasource as the parent
  3. Set the DefaultMode of  the child to “Insert”

Alternatively, you can put a Button into the EmptyDataTemplate and define the click event handler as follows:

protected void Button1_Click(object sender, EventArgs e)
{
DetailsView1.ChangeMode(DetailsViewMode.Insert);

}

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in