Getting Started with the ADO.NET Entity Framework Part 4

  3. Specify the Connection String and DefaultContainerName and then click on Next. 4. Specify the fields you would want to retrieve from the database table and when done click Finish. 5. Drag and drop a GridView control from the toolbox onto the Default.aspx web form as seen below. 6. Use the Choose Data Source option of the GridView control to associate its data source with the Entity Data Source control we created earlier. Refer to the following figure: Below is how the markup code of the GridView control looks with its templates defined. Note how the DataSourceID of the GridView control has been associated with the Entity Data Source control created earlier. <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=
“False” DataKeyNames=”EmployeeID”
DataSourceID=”SqlDataSource1″ BorderColor=”Black” BorderStyle=”Solid” Width=”400px”>
<asp:BoundField DataField=”EmployeeID” HeaderText=”Employee ID” ReadOnly=”True” SortExpression=”EmployeeID” />
<asp:BoundField DataField=”FirstName” HeaderText=
“First Name” SortExpression=”FirstName” />
<asp:BoundField DataField=”LastName” HeaderText=
“Last Name” SortExpression=”LastName” />
<asp:BoundField DataField=”Address” HeaderText=”Address” SortExpression=”Address” />
</asp:GridView> It’s now done! When the application is executed, the output should be similar to what is shown below:   Summary
This series of articles has discussed how to get started with the ADO.NET Entity Framework. Learning how to create an Entity Data Model and use it along with the Entity Data Source control to bind data to a GridView data control. ]]>

Leave a comment

Your email address will not be published.