Академический Документы
Профессиональный Документы
Культура Документы
server, .net and c# video tutorial: Drilldown and display hierarchical data in gridview without using datasource controls - Part 36
Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD
Suggested Videos
Part 33 - Merging cells in gridview footer row
Part 34 - Drilldown and display hierarchical data in gridview using sqldatasource control Best software training and placements in
Part 35 - Drilldown and display hierarchical data in gridview using objectdatasource marathahalli, bangalore. For further
control details please call 09945699393.
Design Patterns
Bootstrap
AngularJS Tutorial
jQuery Tutorial
JavaScript Tutorial
Charts Tutorial
LINQ
LINQ to SQL
Use sql script from Part 34 by clicking here to create and populate the required tables.
LINQ to XML
To retrieve continents, countries and cities data and display in gridview without using
Entity Framework
datasource controls, we need to create respective data access layer class files. We
http://csharp-video-tutorials.blogspot.in/2013/03/drilldown-and-display-hierarchical-data_29.html 1/5
8/28/2017 Sql server, .net and c# video tutorial: Drilldown and display hierarchical data in gridview without using datasource controls - Part 36
discussed about this in Part 35. Click here if you need this code. WCF
Now drag and drop 3 gridview controls on webform1.aspx. ASP.NET Web Services
GridView
ASP.NET MVC
Slides
Entity Framework
WCF
C#
Configure GridView2, to include 2 TemplateFields and 2 BoundFields.
1. The first TemplateField should contain an ItemTemplate, which includes a linkbutton, SQL Server
that the user can click.
2. Set the CommandName property of the LinkButton to SelectCities. ADO.NET
3. The first TemplateField should contain an ItemTemplate, which includes a Label
control, that binds to CountryId coulmn. ASP.NET
4. The first BoundField get it's data from CountryName column.
GridView
5. The second BoundField get it's data from ContinentId column.
6. Set AutoGenerateColumns property of GridView2 to false. ASP.NET MVC
7. Set GridView2 property, DataKeyNames="CountryId".
Visual Studio Tips and Tricks
Interview Questions
C#
SQL Server
Written Test
GridView3 does not require any additonal configuration. Just the HTML as shown
below.
Now generate RowCommand event handler methods for GridView1 and GridView2.
http://csharp-video-tutorials.blogspot.in/2013/03/drilldown-and-display-hierarchical-data_29.html 2/5
8/28/2017 Sql server, .net and c# video tutorial: Drilldown and display hierarchical data in gridview without using datasource controls - Part 36
At this point the HTML on WebForm1.aspx should be as shown below.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton CommandName="SelectCountries"
ID="btnSelectCountries"
runat="server">Select</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Continent Id">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("ContinentId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ContinentName"
HeaderText="Continent Name" />
</Columns>
</asp:GridView>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false"
onrowcommand="GridView2_RowCommand" DataKeyNames="CountryId">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton CommandName="SelectCities" ID="btnSelectCities"
runat="server">Select</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country Id">
<ItemTemplate>
<asp:Label ID="Label2" runat="server"
Text='<%# Bind("CountryId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CountryName" HeaderText="Country Name" />
<asp:BoundField DataField="ContinentId" HeaderText="Continent Id" />
</Columns>
</asp:GridView>
<asp:GridView ID="GridView3" runat="server">
</asp:GridView>
http://csharp-video-tutorials.blogspot.in/2013/03/drilldown-and-display-hierarchical-data_29.html 3/5
8/28/2017 Sql server, .net and c# video tutorial: Drilldown and display hierarchical data in gridview without using datasource controls - Part 36
GridView2.DataSource =
CountryDataAccessLayer.GetCountriesByContinent(continentId);
GridView2.DataBind();
GridView1.SelectRow(rowIndex);
if (GridView2.SelectedValue != null)
{
GridView3.DataSource =
CityDataAccessLayer.GetCitiesByCountryId(Convert.ToInt32(GridView2.SelectedValue)
);
GridView3.DataBind();
}
}
}
GridView3.DataSource = CityDataAccessLayer.GetCitiesByCountryId(countryId);
GridView3.DataBind();
GridView2.SelectRow(rowIndex);
}
}
3 comments:
Replies
http://csharp-video-tutorials.blogspot.in/2013/03/drilldown-and-display-hierarchical-data_29.html 4/5