Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

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 on Thursday, March 1, 2007 9:25 PM ASP.NET | Back to top


Comments on this post: "VB Master-Details Insert" QuickStart sample should work for empty table.

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net