Hi I am Working on asp Grid by getting datas from one table and Updating details from other table
What I have tried:
<pre>
Alter procedure [dbo].[Sampe3](@years int,@months int)
as
;with t1 as (
SELECT DeptID, COUNT(EmpID) AS TotalHeadCount FROM EmployeeDetails
WHERE (datepart(yyyy,DOJ) between 2005 and @years) and Status =0
group by DeptID
),
t2 as (
SELECT DeptID,COUNT(EmpID) AS NewJoinees FROM EmployeeDetails AS EmployeeDetails_7
WHERE (DATEPART(yyyy, DOJ) = @years) AND (DATEPART(mm, DOJ) = @months) and datepart(mm,DOJ)>= @months and Status = 0
group by DeptID
),
t3 as (
SELECT DeptID,COUNT(EmpID) AS Resigned FROM EmployeeDetails AS EmployeeDetails_7
WHERE (DATEPART(yyyy, deactivate) = @years) AND (DATEPART(mm, deactivate) = @months) and datepart(mm,deactivate)>= @months and Status =1 group by DeptID
)
Select t1.DeptID, CASE WHEN TotalHeadCount IS NULL THEN '0' ELSE TotalHeadCount END AS TotalHeadCount,CASE WHEN NewJoinees IS NULL THEN '0' ELSE NewJoinees END AS NewJoinees,CASE WHEN Resigned IS NULL THEN '0' ELSE Resigned END AS Resigned, '' as ToBeHired, '' as OpenPositions, '' as Status
from t1 full outer join t2 on t1.DeptID = t2.DeptID
full outer join t3 on t1.DeptID = t3.DeptID
union
Select 'ZTotal' as total, '' as TotalHeadCount, '' as NewJoinees, '' as Resigned, '' as ToBeHired, '' as OpenPositions, '' as Status
(Update RecruitmentDetails set Tobehired=@Tobehired, OpenPosition=@OpenPosition, Status=@Status) As Update
<asp:GridView ID="grdvEmployeeLeaveUpdate" runat="server" DataKeyNames=""
class="table table-bordered table-striped table-hover" DataSourceID="SqlDataSourceHeadCount"
OnRowDataBound="grdvEmployeeLeaveUpdate_RowDataBound" Width="100%"
OnRowDeleting="grdvEmployeeLeaveUpdate_RowDeleting"
OnRowEditing="grdvEmployeeLeaveUpdate_RowEditing"
OnRowUpdating="grdvEmployeeLeaveUpdate_RowUpdating"
OnRowCancelingEdit="grdvEmployeeLeaveUpdate_RowCancelingEdit"
OnPageIndexChanging="grdvEmployeeLeaveUpdate_PageIndexChanging">
<Columns>
<asp:BoundField DataField="DeptID" HeaderText="Cost Center" ReadOnly="true" ControlStyle-Width="50px" />
<asp:BoundField DataField="TotalHeadCount" HeaderText="HeadCount" ReadOnly="true" ControlStyle-Width="50px" />
<asp:BoundField DataField="NewJoinees" HeaderText="Additions" ReadOnly="true" ControlStyle-Width="50px" />
<asp:BoundField DataField="Resigned" HeaderText="Separations" ReadOnly="true" ControlStyle-Width="50px" />
<asp:BoundField DataField="ToBeHired" HeaderText="To Be Hired" ControlStyle-Width="50px" />
<asp:BoundField DataField="OpenPositions" HeaderText="Open Position" ControlStyle-Width="50px" />
<asp:BoundField DataField="Status" HeaderText="Status" ControlStyle-Width="50px" />
<asp:CommandField HeaderText="Update" ShowEditButton="True" ControlStyle-Width="50px" />
</Columns>
<HeaderStyle></HeaderStyle>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceHeadCount" runat="server" ConnectionString="<%$ ConnectionStrings:TimeSheetConnectionString2 %>"
SelectCommandType="StoredProcedure" SelectCommand="Sampe3">
<SelectParameters>
<asp:ControlParameter ControlID="ddlMonths" Name="months" Type="Int32" />
<asp:ControlParameter ControlID="ddlyear" Name="years" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>