views:

1225

answers:

2

I have an EmptyDataTemplate in my asp:ListView which I want to use to insert a new record.

I have Inserting working in the InsertItemTemplate... I thought I could copy the InsertItemTemplate into the EmptyDataTemplate, on clicking Insert this gives the error

Insert can only be called on an insert item. Ensure only the InsertTemplate has a button with CommandName=Insert.

How can I use the EmptyDataTemplate to Insert a row? Do I need to use the OnClick of the button to access the values within the EmptyDataTemplate and do an Insert by myself?

I'm using LinqDataSource

+1  A: 

No way if want to insert data in empty data template.

kingofswing
+1  A: 

You might have figured it by now but if you set the InsertItemPosition to anything other than None the EmptyData Template will not be rendered i.e it will always show the insert template

you can read more here http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.emptydatatemplate.aspx

Pankaj Kumar