I have checked your. There is no page postback happen.
There might be others causing the issue. You need to check that.
Refer the code that i implemented with datatable as per your provided html and code.
HTML
<form runat="server" role="form" class="form-horizontal">
<asp:ScriptManager ID="scrManager" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="upPnl" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<div class="well" style="width:90%">
<div class="form-group">
<label class="control-label col-md-2">Department <span style="color: red">*</span></label>
<div class="col-md-4">
<asp:DropDownList ID="CmbDepartment" CssClass="form-control" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="CmbDepartment_SelectedIndexChanged">
</asp:DropDownList>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<asp:GridView ID="GridView1" runat="server" Font-Size="Small" AutoGenerateColumns="False"
CssClass="table table-striped table-bordered table-hover table-responsive table-colored table-info"
EmptyDataText="No records has been added." OnRowDataBound="GridView1_RowDataBound" Width="90%">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Select">
<HeaderTemplate>
<asp:CheckBox ID="chkdetails" runat="server" />
All
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chk2" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="emp_fullname" HeaderText="Employee" />
<asp:BoundField DataField="EMP_ID" HeaderText="EMP ID" />
<asp:TemplateField HeaderText="Assigned Leave">
<ItemTemplate>
<asp:DropDownList ID="CmbEmpLeave" runat="server" CssClass="col-md-12 form-control">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Days">
<ItemTemplate>
<asp:TextBox ID="txtDays" CssClass="col-md-12 form-control" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Type">
<ItemTemplate>
<asp:DropDownList ID="CmbDateType" CssClass="col-md-12 form-control" AutoPostBack="true" runat="server" OnSelectedIndexChanged="CmbDateType_SelectedIndexChanged">
<asp:ListItem Text="Select Date Type" Value="0" Selected="True" />
<asp:ListItem Text="English" Value="1" />
<asp:ListItem Text="Nepali" Value="2" />
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Month">
<ItemTemplate>
<asp:DropDownList ID="CmbMonth" runat="server" CssClass="col-md-12 form-control">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
loadDepartment();
}
}
public void loadDepartment()
{
DataTable dt = getDepartment();
CmbDepartment.DataSource = dt;
CmbDepartment.DataTextField = "DEPT_NAME";
CmbDepartment.DataValueField = "DEPT_ID";
CmbDepartment.DataBind();
CmbDepartment.Items.Insert(0, "Select Department");
}
protected void CmbDepartment_SelectedIndexChanged(object sender, EventArgs e)
{
string dept_id = CmbDepartment.SelectedValue;
DataTable dt = getEmployeeListByDepartmentId(dept_id);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList CmbEmpLeave = (DropDownList)e.Row.FindControl("CmbEmpLeave");
int emp_id = Convert.ToInt32(e.Row.Cells[2].Text);
DataTable dtP = getleave_emp(emp_id);
CmbEmpLeave.DataSource = dtP;
CmbEmpLeave.DataTextField = "Leave_name";
CmbEmpLeave.DataValueField = "leave_id";
CmbEmpLeave.DataBind();
CmbEmpLeave.Items.Insert(0, "Select");
CmbEmpLeave.Items[0].Selected = true;
CmbEmpLeave.Items[0].Attributes["disabled"] = "disabled";
}
}
protected void CmbDateType_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = (sender as DropDownList).NamingContainer as GridViewRow;
string ssss = (sender as DropDownList).SelectedValue;
DataSet ds;
if (ssss == "1")
{
ds = GetData("1");
}
else
{
ds = GetData("2");
}
DropDownList CmbMonth = row.FindControl("CmbMonth") as DropDownList;
CmbMonth.DataSource = ds;
CmbMonth.DataTextField = "MONTH_Name";
CmbMonth.DataValueField = "MONTH_ID";
CmbMonth.DataBind();
}
private DataTable getDepartment()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[]
{
new DataColumn("DEPT_ID"),
new DataColumn("DEPT_NAME")
});
dt.Rows.Add(1, "IT");
dt.Rows.Add(2, "CS");
dt.Rows.Add(3, "Admin");
return dt;
}
private DataTable getEmployeeListByDepartmentId(string dept_id)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[]
{
new DataColumn("EMP_ID"),
new DataColumn("emp_fullname"),
new DataColumn("dept_id")
});
dt.Rows.Add(1, "Name 1", 1);
dt.Rows.Add(2, "Name 2", 3);
dt.Rows.Add(3, "Name 3", 3);
dt.Rows.Add(4, "Name 4", 2);
dt.Rows.Add(5, "Name 5", 1);
dt.Rows.Add(6, "Name 6", 1);
return dt.Select("dept_id='" + dept_id + "'").CopyToDataTable();
}
private DataTable getleave_emp(int emp_id)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[]
{
new DataColumn("leave_id"),
new DataColumn("Leave_name"),
new DataColumn("EMP_ID")
});
dt.Rows.Add(1, "Leave 1", 1);
dt.Rows.Add(2, "Leave 2", 3);
dt.Rows.Add(3, "Leave 3", 2);
dt.Rows.Add(4, "Leave 4", 2);
dt.Rows.Add(5, "Leave 5", 1);
dt.Rows.Add(6, "Leave 6", 3);
dt.Rows.Add(7, "Leave 7", 4);
dt.Rows.Add(8, "Leave 8", 5);
dt.Rows.Add(9, "Leave 9", 6);
dt.Rows.Add(10, "Leave 10", 4);
dt.Rows.Add(11, "Leave 11", 5);
dt.Rows.Add(12, "Leave 12", 6);
return dt.Select("EMP_ID=" + emp_id).CopyToDataTable();
}
private DataSet GetData(string language)
{
DataSet ds = new DataSet();
DataTable dtEnglish = new DataTable();
dtEnglish.Columns.AddRange(new DataColumn[]
{
new DataColumn("MONTH_ID"),
new DataColumn("MONTH_Name")
});
dtEnglish.Rows.Add(1, "Baishakh");
dtEnglish.Rows.Add(2, "Jestha");
dtEnglish.Rows.Add(3, "Ashadh");
dtEnglish.Rows.Add(4, "Shrawan");
dtEnglish.Rows.Add(5, "Bhadra");
dtEnglish.Rows.Add(6, "Ashwin");
dtEnglish.Rows.Add(7, "Kartik");
dtEnglish.Rows.Add(8, "Mangsir");
dtEnglish.Rows.Add(9, "Poush");
dtEnglish.Rows.Add(10, "Magh");
dtEnglish.Rows.Add(11, "Falgun");
dtEnglish.Rows.Add(12, "Chaitra");
DataTable dtNepal = new DataTable();
dtNepal.Columns.AddRange(new DataColumn[]
{
new DataColumn("MONTH_ID"),
new DataColumn("MONTH_Name")
});
dtNepal.Rows.Add(1, "वैशाख");
dtNepal.Rows.Add(2, "ज्येष्ठ");
dtNepal.Rows.Add(3, "आषाढ़");
dtNepal.Rows.Add(4, "श्रावण");
dtNepal.Rows.Add(5, "भदौ");
dtNepal.Rows.Add(6, "आश्विन");
dtNepal.Rows.Add(7, "कात्तिक");
dtNepal.Rows.Add(8, "मार्गशीर्ष");
dtNepal.Rows.Add(9, "पौष");
dtNepal.Rows.Add(10, "माघ");
dtNepal.Rows.Add(11, "फाल्गुण");
dtNepal.Rows.Add(12, "चैत्र");
ds.Tables.Add(language == "1" ? dtEnglish : dtNepal);
return ds;
}
Screenshot