Question: (Display Authors Table App Modification) Modify the app in Section 22.5 to contain a Text- Box and a Button that allow the user to search

(Display Authors Table App Modification) Modify the app in Section 22.5 to contain a Text- Box and a Button that allow the user to search for specific authors by last name. Include a Label to identify the TextBox. Using the techniques presented in Section 22.9, create a LINQ query and change the DataSource property of authorBindingSource to contain only the specified authors. Also, provide a Button that enables the user to return to browsing the complete set of authors.

App in section 22.5:

Fig. 22.20: DisplayAuthorsTable.cs

// Displaying data from a database table in a DataGridView.

using System;

using System.Data.Entity;

using System.Data.Entity.Validation;

using System.Linq;

using System.Windows.Forms;

namespace DisplayTable

{

public partial class DisplayAuthorsTable : Form

{

// constructor

public DisplayAuthorsTable()

{

InitializeComponent();

} // end constructor

// Entity Framework DbContext

// load data from database into DataGridView

private void DisplayAuthorsTable_Load( object sender, EventArgs e )

{

// load Authors table ordered by LastName then FirstName

// specify DataSource for authorBindingSource

} // end method DisplayAuthorsTable_Load

// click event handler for the Save Button in the

// BindingNavigator saves the changes made to the data

private void authorBindingNavigatorSaveItem_Click(

object sender, EventArgs e )

{

// try to save changes

try

{

} // end try

catch( )

{

MessageBox.Show( "FirstName and LastName must contain values",

"Entity Validation Exception" );

} // end catch

} // end method authorBindingNavigatorSaveItem_Click

} // end class DisplayAuthorsTable

} // end namespace DisplayTable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!