ASP.NET GridView Tutorial
Lesson 190 of 301 · Working with detailsview without using datasource controls – Part 39 · Database
Working with detailsview without using datasource controls – Part 39
Link for csharp, asp.net, ado.net, dotnet basics and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat/playlists
Link for text version of this video
http://csharp-video-tutorials.blogspot.com/2013/03/working-with-detailsview-without-using.html
In Part 37 of asp.net gridview tutorial, we discussed about using sqldatasource control with detailsview, and in Part 38, we discussed about using objectdatasource control. In this video, we will discuss about working with detailsview without using any datasource control.
In a gridview control, I just want to show 3 columns (Id, FirstName and City) from tblEmployee table. As soon as I select a row, in the gridview control, then all the columns of the selected row, should be displayed in details view control.
We will be using tblEmployee table for this demo. If you need sql script to create this table, please refer to Part 37, using the link below.
http://csharp-video-tutorials.blogspot.com/2013/03/detailsview-in-aspnet-part-37.html
We will be using EmployeeDataAccessLayer, that we coded in Part 38. If you need EmployeeDataAccessLayer code, please refer to Part 38.
http://csharp-video-tutorials.blogspot.com/2013/03/using-objectdatasource-control-with.html
Drag and drop a gridview control and a detailsview control on webform1.aspx.
1. Configure GridView1, to include 1 TemplateField and 3 BoundFields.
2. The TemplateField should contain an ItemTemplate, which includes a linkbutton, that the user can click.
3. Set the CommandName property of the LinkButton to SelectFullDetails.
4. Configure the rest of the BoundFields to get data from Id, FirstName and City properties.
5. Set AutoGenerateColumns property of GridView1 to false.
6. Finally generate RowCommand event handler method for GridView1.
7. Set DataKeyNames property of GridView1
DataKeyNames=”Id”