<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label1" Visible=false runat="server" Text='<%# Bind("id") %>'></asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("sec") %>'></asp:Label>
<br />
<asp:GridView ID="GridView2" DataKeyNames="id" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbRecruitmentConnectionString %>"
SelectCommand="uspChild" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="Label1" Name="id" PropertyName="Text"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbRecruitmentConnectionString %>"
SelectCommand="uspParent" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
-----------------------------------------------------------
alter procedure uspParent
as
begin
select ID=1,sec='sec1' into #temp
insert into #temp
select ID=2,sec='sec2'
insert into #temp
select ID=3,sec='sec3'
select * from #temp order by id
drop table #temp
End
alter procedure uspChild
@id int
as
begin
select id=1 ,chapter='Chap1', days=' 2 Days ' into #temp
insert into #temp
select id=1, chapter='Chap2', days=' 5 Days '
insert into #temp
select id=1, chapter='Chap3', days=' 2 Days '
insert into #temp
select id=2, chapter='Chap1', days=' 2 Days '
insert into #temp
select id=2, chapter='Chap2', days=' 2 Days '
insert into #temp
select id=2, chapter='Chap3', days=' 2 Days '
select * from #temp where id=@id order by id
drop table #temp
end
-------------------------------------------------------
Use proper connection string in your web.config
Thanks,
Sanjay
Sampath1750, if this helps please login to Mark As Answer. | Alert Moderator