i have drop down in the form,and an event is fire when any value is selected.
in the database have a table there are two column one is link with drop down against each value of this there are multiple value in the 2nd column, how can i count and display these value in the textboxes of the form.
<div class="form-group">
<label class="col-sm-2 control-label">
Select Sector:
</label>
<div class="col-sm-3">
<asp:DropDownList CssClass="form-control" runat="server" MaxLength="7" ID="ddlToSector" OnSelectedIndexChanged="ddlToSector_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
</div>
<label class="col-sm-2 control-label">
Strenght:
</label>
<div class="col-sm-1">
<asp:TextBox runat="server" ID="txtStrenght" AutoPostBack="true" ></asp:TextBox>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
OnLeave:
</label>
<div class="col-sm-3">
<asp:TextBox runat="server" ID="txtOnLeave" AutoPostBack="true" ></asp:TextBox>
</div>
<label class="col-sm-2 control-label">
Absent:
</label>
<div class="col-sm-3">
<asp:TextBox runat="server" ID="txtAbsent" AutoPostBack="true"></asp:TextBox>
</div>
</div>
c#
protected void ddlToSector_SelectedIndexChanged(object sender, EventArgs e)
{
var sectorStrength = _service.GetAllEmployeeDuty().Where(x =>
x.ToSector_Id == SafeConvert.ToInt32(ddlToSector.SelectedValue));
txtStrenght.Text = sectorStrength.ToString();
var sectorAbsent = _service.GetAllEmployeeAbsent().Where(x =>
x.Sector_Id ==SafeConvert.ToInt32(ddlToSector.SelectedValue)).Count();
txtAbsent.Text = sectorAbsent.ToString();
var empStatus = _service.GetAllEmployeeStatus().Where(x =>
x.Rank_Id == SafeConvert.ToByte(ddlToSector.SelectedValue)).Count();
txtSpecialDuty.Text = empStatus.ToString();
First sectorStrenght work fine ,it return exact value from the table
problem is in EmployeeStatus table in which i have different value against same Sector Id,
i want that when any sector is selected query will check in this table againt Sector ID DIFFERENT status of employee then count it and return in to text box
Here is EmployeeStatusType table.
USE [CTPHR]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[EmployeeStatusType_Id](
[Id] [tinyint] IDENTITY(1,1) NOT NULL,
[Name] [varchar](25) NOT NULL,
[IsDutable] [bit] NOT NULL,
CONSTRAINT [PK_EmployeeStatusType_Id] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
this is 2nt table against sector id there are different employeestatustype ,this sector id is used to fire an event .
USE [CTPHR]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[EmployeeStatus](
[Id] [tinyint] IDENTITY(1,1) NOT NULL,
[Employee_Id] [varchar](8) NOT NULL,
[EmpstatusType_Id] [tinyint] NOT NULL,
[StartDate] [date] NOT NULL,
[EndDate] [date] NOT NULL,
[Sector_Id] [smallint] NOT NULL,
CONSTRAINT [PK_Mp_status] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[EmployeeStatus] WITH CHECK ADD CONSTRAINT [FK_EmployeeStatus_EmployeeStatus] FOREIGN KEY([Id])
REFERENCES [dbo].[EmployeeStatus] ([Id])
GO
ALTER TABLE [dbo].[EmployeeStatus] CHECK CONSTRAINT [FK_EmployeeStatus_EmployeeStatus]
GO
[Id] [Employee_Id] [EmpstatusType_Id][StartDate][EndDate][Sector_Id]
1 333 1 xxx xxx 1
2 ddd 1 xxx xxx 1
3 www 2 xxx xxx 1
4 fff 4 xxx xxx 1
5 ddd 3 xxx xxx 1
this is the format of database records.there are different value against same sector. how can calculate EmpstatusType_Id ,how can i calculate empstatusType and show them in text box.as explain above