"VB Master-Details Insert" QuickStart sample should work for empty table.

I've used VB Master-Details Insert QuickStart sample in my application.It works relatively good(if ignore System.InvalidOperationException: ObjectDataSource '...' could not find a non-generic method 'Update' that has parameters error).
However to create a new record,you need to have DetailsView visible. However if the GridView is empty, DetailsView is not visible and user is uable to create the first record.

I've added code to show DetailsView in DefaultMode="Insert" if no data was selected in the list

        Private Sub odsGoogleAPIKeys_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs) Handles odsGoogleAPIKeys.Selected

            'from http://www.thescripts.com/forum/post1823472-2.html

            Dim dt As DataTable = e.ReturnValue 

            Dim count As Integer = dt.Rows.Count

            'If (e.AffectedRows > 0) Then 'NOT working, returns -1 '/from    http://forums.asp.net/ShowPost.aspx?PostID=1539233

            If (count = 0) Then

                DetailsView1.Visible = True

                DetailsView1.DefaultMode = DetailsViewMode.Insert

            End If

        End Sub

Alternatively it was possible to add a link "Add a new record",similar to what exist on a sampe GridViewMasterDetailsInsertPage. to show DetailsView in DefaultMode="Insert".

posted @ Thursday, March 01, 2007 9:25 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 7 and 2 and type the answer here:
 

Live Comment Preview:

 
«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456