Hi Frits,
The SqlDataSource raises an event named "Selected". It is triggered after
the SqlDataSource object executed the Select command. You can check the
AffectedRows in handling this event and if it is zero then set the
DetailsView mode to Insert.
1- In the Page_init or Page_Load wire up an event handler for the Selected
event of the SqlDataSource:
SqlDataSource1.Selected += new
SqlDataSourceStatusEventHandler(SqlDataSource1_Selected);
2- Write an eventhandler like this:
Void SsqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
if(e.AffectedRows==0)
{
DetailsView1.ChangeMode(DetailsViewMode.Insert);
}
}
--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
Frits van Soldt said:
In the detailsview you can add a 'new' button to add new records. This works
fine if there are already some records in the table. But when the table is
empty, the button is not shown, thus not allowing to create any records! How
can I show the button even if there are no records?