private void resetPage()
 {
     TxtBox_UserId.Enabled = true;
     TxtBox_UserId.Text    = "";
     TxtBox_Password.Attributes.Add("value", "");
     TxtBox_RetypePass.Attributes.Add("value", "");
     TxtBox_EmpName.Text = "";
     Btn_Save.Text       = "Save";
     DropDownList_Active.SelectedIndex       = 0;
     SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, " +
                                               "UserInfo.Enabled, BranchInfo.BranchName FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = " +
                                               "UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.BranchCode = " +
                                               "BranchInfo.BranchCode WHERE (BranchInfo.BrId = @BrId)";
     //SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, UserInfo.Enabled, BranchInfo.BranchName, UserInfo.RoutNo FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.RoutNo = BranchInfo.RoutingNo AND UserInfo.BranchCode = BranchInfo.BranchCode WHERE (UserInfo.RoutNo = @RoutNo)";
     //SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, UserInfo.Enabled, BranchInfo.BranchName, UserInfo.RoutNo FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.RoutNo = BranchInfo.RoutingNo WHERE (UserInfo.RoutNo = @RoutNo)";
     GridView_NewUser.DataBind();
 }
    protected void DropDownList_Br_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        using (SqlConnection conn = new SqlConnection(strConnection))
            using (SqlCommand cmd = new SqlCommand("SELECT RoutingNo FROM BranchInfo WHERE (BrId = " + DropDownList_Br.SelectedValue.ToString() + ")", conn))
            {
                try
                {
                    conn.Close();
                    cmd.CommandType = CommandType.Text;
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        NB_BranchCode.Text = dt.Rows[0][0].ToString();
                    }
                }
                catch (Exception eX)
                {
                    Lbl_Message.Text = "Error on : " + eX.Message;
                }
                finally
                {
                    if (conn.State != ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }
        if (!TxtBox_UserId.Enabled)
        {
            resetPage();
        }
        else
        {
            SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, " +
                                                      "UserInfo.Enabled, BranchInfo.BranchName FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = " +
                                                      "UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.BranchCode = " +
                                                      "BranchInfo.BranchCode WHERE (BranchInfo.BrId = @BrId)";
            //SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, UserInfo.Enabled, BranchInfo.BranchName FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.BranchCode = BranchInfo.BranchCode WHERE (UserInfo.RoutNo = @RoutNo)";
            //SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, UserInfo.Enabled, BranchInfo.BranchName FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.BranchCode = BranchInfo.BranchCode WHERE (BranchInfo.BranchCode = @BranchCode)";
            GridView_NewUser.DataBind();
        }
    }
 protected void DropDownList_Br_DataBound(object sender, EventArgs e)
 {
     NB_BranchCode.Text = DropDownList_Br.SelectedValue.ToString();
     SqlDataSource_UserDetails.SelectCommand = "SELECT UserInfo.UserId, UserInfo.EmployeeName, DesignationInfo.Designation, UserTypeInfo.UserType, UserInfo.Enabled, BranchInfo.BranchName, UserInfo.RoutNo FROM DesignationInfo INNER JOIN UserInfo ON DesignationInfo.DesignationId = UserInfo.DesignationId INNER JOIN UserTypeInfo ON UserInfo.UserTypeId = UserTypeInfo.UserTypeId INNER JOIN BranchInfo ON UserInfo.RoutNo = BranchInfo.RoutingNo WHERE (BranchInfo.BrId = @BrId)";
     GridView_NewUser.DataBind();
 }